[ACCEPTED]-How to add multiple redirect URIs for Google OAuth 2?-social-authentication
It's actually easier than you think, unfortunately, it 12 took me a couple of hours to figure it out.
How can I add multiple redirect_uris to my app?
Normally 11 when you add multiple links to something 10 on Google or elsewhere you separate it by 9
; but with Redirect URIs you have to 8 use a new line, it's actually not very intuitive. So 7 when you press the
Edit Settings button, you can add 6 to the URI and/or Origins if you have a 5 couple more links, separated by newlines 4 (
No need for complicated app configurations 3 or new keys.
Why is Google identifying my app as "Project Default Service Account" rather than "My Hobby App"?
On your second question: You 2 have to go to the "Consent Screen" tab 1 to change your app info such as your
This answer may not be an exact answer to 42 the question, but I think this might help 41 those who are using Google OAuth for the 40 first time and are wondering why their multiple 39 URIs are not being recognized.
We use the 38 redirect URI at 2 places in the code. First 37 time, while fetching the auth code and a 36 second time, when exchanging this code for 35 an access token.
In the Google docs, it is clearly 34 mentioned that the response for the auth 33 code request(1st request) will be sent to 32 the redirect URI. So, if you make the request 31 from an endpoint A and specify the rediredt 30 URI as endpoint B, Google will send the 29 auth code to endpoint B. This is clear and 28 worked fine without any errors.
Coming to 27 the second request, the documentation is 26 somewhat ambiguous. The redirect_URI parameter 25 is described as below:
redirect_uri: The 24 URI that you specify in the API Console, as 23 described in Set a redirect URI.
This is 22 where I made a mistake in understanding 21 how this works. Following a similar approach 20 to the first call, I used a third endpoint 19 C and passed this endpoint C in the redirect_URI 18 parameter while making the second call. I 17 got a URI mismatch error although my endpoints 16 B and C are specified in the API console.
The 15 problem is that, unlike in the case of first 14 call, the response to the second call comes 13 to the same endpoint from where the request 12 is made. I made a request in python like 11 below:
r = requests.post(token_endpoint, params)
r has the response with the token.
I 10 was getting a URI mismatch because, I am 9 supposed to use the same redirect_URI in 8 both the calls.
So, for a single OAuth request, we 7 need to use a single redirect_URI.
But then, that 6 brings up the question, why are multiple 5 redirect_URIs allowed in the API console 4 for a single app. I am assuming that if 3 we need to make multiple pairs of authCode-token 2 calls in the same app, we have the leeway 1 of using multiple redirect_URIs.
More Related questions