Hello, for my webapp, i’m working on 3 differents environment :
Localhost
Staging
Production
Can I add multiple redirect uri like :
http://localhost/auth/
https://staging.xxxxx.com/auth/
https://mydomain.com/auth/
Because I try to do that and all environments returning
400 - Parameter redirect_uri does not match registered URI
Obviously I change the auth url on each environment
https\://id.twitch.tv/oauth2/authorize?response_type=code&client_id=xxxxxxxxxxxxxxxxxxx&redirect_uri='[CHANGE HERE]','oAuth','width=490,height=850
Thanks by advence !
Yes. A clientID supports multple callbacks
Commonly the issue is that redirect_uri
in your outbound redirect is missing the ending /
or you didn’t URIEncode.
So uou said “my redirect is http://localhost/auth
”
And
http://localhost/auth
!= http://localhost/auth/
The have to exact match and the common issue people do is the miss the /
on the end leading to a mismatch. Either from not writing the /
in code or not URIEncoding and the URI becoming confused when a URI is in a URI
Everything seems fine, I retry to do my localhost but isn’t working :
window.open('https\://id.twitch.tv/oauth2/authorize?response_type=code&client_id=7d64ygbjjq2hk7z9lmtcdv7ta8a6i8&redirect_uri=http://localhost/auth/','oAuth','width=490,height=850')
try
window.open('https\://id.twitch.tv/oauth2/authorize?response_type=code&client_id=7d64ygbjjq2hk7z9lmtcdv7ta8a6i8&redirect_uri=' + encodeURIComponent('http://localhost/auth/'),'oAuth','width=490,height=850')
Similar to this example Twitch Implicit Auth Example
BarryCarlyon:
window.open('https\://id.twitch.tv/oauth2/authorize?response_type=code&client_id=7d64ygbjjq2hk7z9lmtcdv7ta8a6i8&redirect_uri=' + encodeURIComponent('http://localhost/auth/'),'oAuth','width=490,height=850')
This did’nt solve the problem, same error, but I identify the issue
My error was not on the fallback code, but on the token fetch, I chage redirect URI for all but not on the token request ^^
Sorry for that totally my bad, thanks a lot
All good.
It’s also good practice to URI encode your redirect URI’s an outbound oAuth URL
Yeah I did that with all the redirect URI, I did not know this principle of encoding !
system
Closed
May 20, 2022, 11:54am
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.