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

Unable to get access token, 'code' param invalid. #239

Closed
Itsindigo opened this issue Oct 18, 2017 · 5 comments
Closed

Unable to get access token, 'code' param invalid. #239

Itsindigo opened this issue Oct 18, 2017 · 5 comments

Comments

@Itsindigo
Copy link

Itsindigo commented Oct 18, 2017

I was hoping somebody might be able to help, I'm having issues getting an access token from the API. I've reviewed against #71 which feels like a similar issue, but no luck.

One potential issue I can think of is that I'm manually grabbing the code out of the URL from my auth redirect. Could the code be expiring in the 30s or so it takes me to grab it and add into my code?

data = json.dumps({
    'grant_type': 'authorization_code',
    'code': '[Code just returned from auth redirect]'
})

rsp = requests.post(
    url='https://www.bungie.net/Platform/App/GetAccessTokensFromCode/',
    headers={
        'X-API-KEY': settings.API_KEY
    },
    data=data,
)

output is:

(Pdb) rsp.json()
{'ErrorCode': 2106, 'ThrottleSeconds': 0, 'Message': 'Authorization code is invalid.', 'MessageData': {}, 'ErrorStatus': 'AuthorizationCodeInvalid'}

Thanks.

@Itsindigo Itsindigo changed the title Authorization Code Invalid issue? Unable to get access token, 'code' param invalid. Oct 18, 2017
@floatingatoll
Copy link

floatingatoll commented Oct 18, 2017 via email

@Itsindigo
Copy link
Author

Itsindigo commented Oct 18, 2017

Thanks @floatingatoll, the response code is 32 chars long, which looks to be correct based on the response shown in the docs. As for the grant_type, it doesn't seem to make a difference to the response either way.

@Tetron-bng
Copy link

@Itsindigo The https://www.bungie.net/Platform/App/GetAccessTokensFromCode/ is strictly for the 'almost OAuth' mechanism we originally supported on Bungie.net. New implementations should be using Token Endpoint: https://www.bungie.net/platform/app/oauth/token/

More here:

https://www.bungie.net/en/Groups/Post?groupId=39966&postId=227773391&sort=0&page=0

I still have not updated the help article with the OAuth details. This is on my backlog still.

@dad2cl3
Copy link

dad2cl3 commented Oct 18, 2017

@Itsindigo try this link https://github.com/Bungie-net/api/wiki/OAuth-Documentation

@Itsindigo
Copy link
Author

Thanks folks, I'll give this another shot.

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

4 participants