Wasabi Thumbs
Wasabi Thumbs

Reputation: 345

Pass a string through Discord OAuth?

I was wondering if it was possible to use Discord OAuth (identify scope) while also passing through important supplemental information to the redirect URL.

site with [important variable] > oauth page > site that needs [important variable] and oauth result

I have tried appending something like ?variable="myString" but it shears off all unnecessary URL parameters other than the OAuth information. Discord OAuth also doesn't really appreciate being in an iframe, so that won't be the solution here.

Upvotes: 9

Views: 3159

Answers (1)

Lev Buchel
Lev Buchel

Reputation: 592

I have written a post regarding this question, you can find it here:

https://levbuchel.com/passing-variables-through-oauth


Original answer:

To pass variables through an oAuth process, you should use the state oAuth parameter.

First create a Json string with your parameters,

for example {'first':'111', 'second':'222'}.

Then encode it to base64 so that it will not be modified when passing as a URL.

Pass this string as a state (api/oauth2/authorize?response_type=token&state=whatEverYouGotAsState).

Then you will be able to receive and decode it back on your redirect URI.

Upvotes: 14

Related Questions