docusignapi - Docusign refresh token - invalid grant - Stack Overflow

I'm currently trying to implement Docusign API. I've setup oauth authorization code flow with

I'm currently trying to implement Docusign API. I've setup oauth authorization code flow with PKCE enabled successfully (with signature extended openid scope). I fetch the token & refresh token without any problem. I'm trying to refresh my token but I keep getting: ["status_code" => 400,"response" => "{"error":"invalid_grant"}"]

  $authHeader = 'Basic ' . base64_encode("{$clientId}:{$clientSecret}");
                $response = $this->httpClient->request('POST', $tokenUrl, [
                    'headers' => [
                        'Authorization' => $authHeader,
                        'Content-Type' => 'application/x-www-form-urlencoded',
                    ],
                    'body' => http_build_query([
                        'grant_type' => 'refresh_token',
                        'refresh_token' => $refreshToken,
                        'client_id' => $clientId,
                        'client_secret' => $clientSecret
                    ]),
                ]);

I tried without client_id and client_secret as parameters as well.

I even tried on their postman collection and I'm getting the same result. postman_capture

My clientId is integration id given on the app settings, my client secret is valid as well since I'm able to do the auth code flow.

I'm expecting to get a new token and refresh_token.

Thanks for your help

I'm currently trying to implement Docusign API. I've setup oauth authorization code flow with PKCE enabled successfully (with signature extended openid scope). I fetch the token & refresh token without any problem. I'm trying to refresh my token but I keep getting: ["status_code" => 400,"response" => "{"error":"invalid_grant"}"]

  $authHeader = 'Basic ' . base64_encode("{$clientId}:{$clientSecret}");
                $response = $this->httpClient->request('POST', $tokenUrl, [
                    'headers' => [
                        'Authorization' => $authHeader,
                        'Content-Type' => 'application/x-www-form-urlencoded',
                    ],
                    'body' => http_build_query([
                        'grant_type' => 'refresh_token',
                        'refresh_token' => $refreshToken,
                        'client_id' => $clientId,
                        'client_secret' => $clientSecret
                    ]),
                ]);

I tried without client_id and client_secret as parameters as well.

I even tried on their postman collection and I'm getting the same result. postman_capture

My clientId is integration id given on the app settings, my client secret is valid as well since I'm able to do the auth code flow.

I'm expecting to get a new token and refresh_token.

Thanks for your help

Share edited Mar 7 at 13:12 Joachim asked Mar 7 at 13:10 JoachimJoachim 111 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

The client_id and client_secret should not be included in the body when using the Authorization header. Your request should look like this:

$authHeader = 'Basic ' . base64_encode("{$clientId}:{$clientSecret}");
$response = $this->httpClient->request('POST', $tokenUrl, [
    'headers' => [
        'Authorization' => $authHeader,
        'Content-Type' => 'application/x-www-form-urlencoded',
    ],
    'body' => http_build_query([
        'grant_type' => 'refresh_token',
        'refresh_token' => $refreshToken,
    ]),
]);

For the developer environment, it should be https://account-d.docusign/oauth/token

Note: Refresh tokens have a lifespan of 30 days. If the token is older than that, it will expire.

Ok I found the problem, token was truncated to 255 char in my db. Thanks for your help

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744927460a4601525.html

相关推荐

  • docusignapi - Docusign refresh token - invalid grant - Stack Overflow

    I'm currently trying to implement Docusign API. I've setup oauth authorization code flow with

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信