Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Document OAuth2 response_type=code

A topic by mathium05 created 35 days ago Views: 441 Replies: 4
Viewing posts 1 to 2

It does exist, and it does work, just the docs just neglect to document it anywhere.

For those trying to do this like I just struggled to do:

1. The secret is not used for response_type=code instead you're expected to do code_challenge

  • Generate a challenge, 64 long chars will do
  • SHA256 hash it then encode it as base64url and send it under the key code_challenge
  • set code_challenge_method to S256
  • When getting your token back include the challenge under the key code_verifier

2. To get the token you need to POST to https://api.itch.io/oauth/token

3. when posting do not include the params as the body, instead it's the search query IE `https://api.itch.io/oauth/token?grant_type=authorization_code&..`

I'm POSTing 

and an empty post body, and getting {"errors":["invalid_grant"]} as a response. Am I missing something?

Moderator(+1)

Does this also happen with a fresh authorization code exchanged immediately, on its first attempt? Could you check that code_verifier is the original unhashed value used to generate the S256 challenge, and that redirect_uri exactly matches the authorization request? Please don't post the code, verifier, or any tokens here.

(+1)

I figured it out! Confused Base64 and Base64URL, now I'm using the latter and it works, thanks! ("invalid_grant" is a bit misleading as an error though.)

I'm glad you were able to figure out the issue, though it's still a bit sad that this post is serving as the documentation for this important feature lol