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 badges2 Answers
Reset to default 1The 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
评论列表(0条)