Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrantNewAccessTokenFromAuthCode doesn't work #41

Closed
NicholasAsimov opened this issue Oct 19, 2017 · 1 comment
Closed

GrantNewAccessTokenFromAuthCode doesn't work #41

NicholasAsimov opened this issue Oct 19, 2017 · 1 comment

Comments

@NicholasAsimov
Copy link
Contributor

NicholasAsimov commented Oct 19, 2017

So it seems like passing json as a body for /v1/identity/openidconnect/tokenservice request doesn't work anymore.

This request doesn't work:

curl -v 'https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice' \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearing <token>" \
    -d '{"grant_type":"authorization_code","code":"<code>","redirect_uri":"<redirect_uri>"}'

response:

{"error_description":"Grant type is null","error":"invalid_grant","correlation_id":"a7087aa10fff1","information_link":"https://developer.paypal.com/docs/api/#errors"}

Where this request using formdata works:

curl -v 'https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice' \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: Basic <base64(clientID:secret)>" \
    -d 'grant_type=authorization_code&code=<code>&redirect_uri=<redirect_uri>' 

Also making GET request with query params also works.

Did I miss something here and I'm incorrect in my assumption? If not, I can provide a pull request that I started to work on. But one issue is that Paypal returns "expire_in" field as a string, so we would need to do something like here for that field where it is a custom type with UnmarshalJSON method: https://github.com/golang/oauth2/blob/master/internal/token.go#L62.

Edit: Also it looks like using a bearing token for authorization doesn't work, but using a basic clientID:secret auth does work. I fixed the cURL example above.

@plutov
Copy link
Owner

plutov commented Oct 26, 2017

Merged, thanks!

@plutov plutov closed this as completed Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants