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

Fetching OAuth access token returns 400 "invalid_grant" #341

Open
stevereinvented opened this issue Oct 24, 2024 · 4 comments
Open

Fetching OAuth access token returns 400 "invalid_grant" #341

stevereinvented opened this issue Oct 24, 2024 · 4 comments

Comments

@stevereinvented
Copy link

Title: Fetching OAuth access token returns 400 "invalid_grant"

Issue found of: October 16th, 2024

Endpoint(s):

POST secure.soundcloud.com/oauth/token

Scope(s):

Application uses authorization_code workflow for authentication

Steps to reproduce:

After authorizing via https://secure.soundcloud.com/authorize with params:

client_id=[redacted]
redirect_uri=[http:// URL]
response_type=code
code_challenge=[code challenge]
code_challenge_method=S256
state=[random]

…attempt to obtain an Access Token from https://secure.soundcloud.com/oauth/token with:

code=[code received from authorize]
client_id=[redacted]
client_secret=[redacted]
redirect_uri=[http:// URL]
grant_type='authorization_code'
code_verifier=[base 64 string used to create the code_challenge]

Expected behaviour:

The Access Token is returned as per https://developers.soundcloud.com/docs/api/guide#auth-code

Actual behaviour:

400 {"error":"invalid_grant"}

This had been working until last week (the issue was noticed on Oct 16), and there have been no changes on our our side.

If it's of any relevance, the redirect URL registered is http:// not https:// and that is what is passed, but the site is HTTPS now.

@youssefhassan
Copy link

Hey @stevereinvented, the redirect Uri is most probably the reason of this error, can you please share your username and app name so I can update the redirect uri for the application?

@stevereinvented
Copy link
Author

Thanks for getting back so quickly, and sorry for the delay my side.

The username is freshnet and the app is "Fresh On The Net Moderator".

@stevereinvented
Copy link
Author

@youssefhassan is there an update on this? Still seeing the same error, and the URL still appears unchanged as beginning with http:// in https://soundcloud.com/you/apps. Thanks.

@youssefhassan
Copy link

Invalid grant can happen when using a wrong code verifier/code challenge pair
I use this one for validating, make sure to press Calculate Hash as it's not generated automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants