oauth2: add new RawBody field to oauth2.Token #432
+9
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability to retrieve the raw HTTP response body from the token authorization flows. This is handy for services such as Slack as they include additional data in the response
For example, taking the Slack v2 oauth.access request https://api.slack.com/methods/oauth.v2.access
Gives you the following response
To gain access to this information a user of the
golang/oauth2
library has to use theoauth2.Token.Extra()
func. This is okay for a few fields and fields that are in the root JSON object but once you start dealing with nested fields this can become cumbersomeThis PR adds the ability for accessing the response body from the Token request and allows a consumer to decode it into a struct to simplify the retrieval of extra fields