I’m building a client-side app that needs to authenticate with Google Drive using OAuth2. I keep getting an error about redirect URI not matching what’s registered.
Here’s my OAuth configuration:
Web Application Credentials
Client ID: 123456789012.apps.googleusercontent.com
Email: [email protected]
Client secret: [hidden]
Redirect URIs: https://myapp.example.com/auth/
https://staging.myapp.com/auth/
JavaScript origins: https://myapp.example.com
https://staging.myapp.com
Drive SDK Credentials
Client ID: 123456789012-abcdef123456789.apps.googleusercontent.com
Client secret: [hidden]
When the user needs to login, I redirect them to:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive.file+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&response_type=token&redirect_uri=https://staging.myapp.com/auth/&client_id=123456789012-abcdef123456789.apps.googleusercontent.com
But Google returns this error:
The redirect URI in the request: https://staging.myapp.com/auth/ did not match a registered redirect URI
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive.file
response_type=token
redirect_uri=https://staging.myapp.com/auth/
client_id=123456789012-abcdef123456789.apps.googleusercontent.com
What could be causing this mismatch? The URLs look identical to me.