TroubleShooting

Interacting with GitHub

GitHub API v3 supports the Authorization Code Flow
in order to obtain access tokens for a registered application. However, the implementation
presents a flaw which makes it not compliant with the official RFC:

By default, GitHub's authorization server will respond with a x-www-form-urlencoded mime-type
when trying to exchange the authorization code against an access token (instead of a
application/json mime-type as specified in the official RFC).

This behavior can be changed by providing an extra Accept: application/json header with the
authenticate request. However, by doing so, GitHub's authorization server will encode the
scope of the response as a comma-separated list (instead of a space-separated list as
specified in the official RFC).

Hence, this library provides a way to work around this implementation quirks by adjusting the
authentication request before it gets sent. To achieve this, one may use the various decoders
now exposed in OAuth.Decode
to craft a custom transformation function for the authenticateWithOpts functions.

Here's a small example of how to work around GitHub's API v3 implementation: