Skip to main content
Question

Receiving 401 Unauthorized when attempting to list users with JWT Token

  • November 26, 2024
  • 3 replies
  • 87 views

Forum|alt.badge.img

I am following the tutorial from this page: How to get an access token with Implicit Grant | Docusign

I have an href to the following URL: https://account-d.docusign.com/oauth/auth?response_type=code&scope=impersonation%20signature%20organization_read%20user_read%20account_read%20dtr.profile.read&client_id=#redacted#&redirect_uri=https://localhost:7054/dsauth


When I follow this href I am directed to log in and grant permission.  I am successfully redirected back to https://localhost:7054/dsauth.  I capture the token from the “code” query parameter.

When I try to use that token in the header to list users, I receive 401 unauthorized.  I can’t find any documentation to help resolve the problem, and as far as I can tell I’m following the example perfectly.

I am using C# and RestSharp to make the calls.  Following is the relevant code:

    async void GetUsers()
    {
        var client = new RestClient("https://account-d.docusign.com/oauth/userinfo");
        var request = new RestRequest();
        request.Method = Method.Get;
        request.AddHeader("Authorization", $"Bearer {AccessToken}");

        var response = await client.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            // Handle successful response
            result = response.Content;
        }
        else
        {
            // Handle error response
            result = response.ErrorMessage;
        }
    }

I’m frustrated and out of ideas.  Any help is appreciated.  Even just a link to relevant documentation.  I’ve tried adding any scope even remotely relevant, and it’s not changing anything.  I can’t see any options in my App Registration screen that seems relevant.

3 replies

Forum|alt.badge.img+3

Hello,

I don’t immediately see anything wrong with your request, but I believe the X-Docusign-Tracetoken that’s returned with the response header would help us to find where the issue is. Can you please open a case through our support site and submit this header so that we can take a look into this for you? Here’s a link to our support site: https://support.docusign.com/s/?language=en_US

Best regards,

Jonathan | Docusign Developer Support


Forum|alt.badge.img+1
  • Newcomer
  • 2 replies
  • December 9, 2024

I’m having the same problem. I thought it was an issue with the scopes, but I tried every one that made sense. I think I only need user_read, but I’ve also tried account_read, and organization_read.

I’ve also confirmed my JWT is correct, the access_token is formatted correctly as “Bearer ….”


Forum|alt.badge.img+1
  • Newcomer
  • 2 replies
  • December 10, 2024
danloughney wrote:

I’m having the same problem. I thought it was an issue with the scopes, but I tried every one that made sense. I think I only need user_read, but I’ve also tried account_read, and organization_read.

I’ve also confirmed my JWT is correct, the access_token is formatted correctly as “Bearer ….”

I solved my issue by using the scopes impersonation and signature. No idea why signature would be the one to give me access to the user listing, but that was it.