java - Google OAUTH: The redirect URI in the request did not match a registered redirect URI -


i trying make upload youtube java based web app, spent few days understand , problem , cannot it, pulling hair out off head.

i registered web app in google console, got pair of client id , secret , possibility download json type file config.

so here config:

{     "web":{         "auth_uri":"https://accounts.google.com/o/oauth2/auth",         "client_secret":"***",         "token_uri":"https://accounts.google.com/o/oauth2/token",         "client_email":"***",         "redirect_uris":["http://localhost:8080/webapp/youtube-callback.html","http://www.webapp.md/youtube-callback.html"],         "client_x509_cert_url":"***",         "client_id":"***",         "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",         "javascript_origins":["http://www.webapp.md/"]     } } 

how possible getting default url google?

the redirect uri in request: http://localhost:8080/callback did not match registered redirect uri

it gives me default http://localhost:8080/callback url instead of mine.

and ide console shows me that:

please open following address in browser: https://accounts.google.com/o/oauth2/auth?client_id=***&redirect_uri=http://localhost:8080/callback&response_type=code&scope=https://www.googleapis.com/auth/youtube.upload attempting open address in default browser now...

i using last version of dependencies: google-api-services-youtube v3-rev99-1.17.0-rc , google-api-services-youtubeanalytics v1-rev35-1.17.0-rc

when browser redirects user google's oauth page, passing parameter redirect uri want google's server return token response? setting redirect uri in console not way of telling google go when login attempt comes in, rather it's way of telling google allowed redirect uris (so if else writes web app client id different redirect uri disallowed); web app should, when clicks "login" button, send browser to:

https://accounts.google.com/o/oauth2/auth?client_id=xxxxx&redirect_uri=http://localhost:8080/webapp/youtube-callback.html&response_type=code&scope=https://www.googleapis.com/auth/youtube.upload 

(the callback uri passed parameter must url-encoded, btw).

when google's server gets authorization user, then, it'll redirect browser whatever sent in redirect_uri. it'll include in request token parameter, callback page can validate token, access token, , move on other parts of app.

if visit:

http://code.google.com/p/google-api-java-client/wiki/oauth2#authorization_code_flow

you can see better samples of java client there, demonstrating have override getredirecturi method specify callback path default isn't used.

the redirect uris in client_secrets.json file multiple reasons ... 1 big 1 oauth flow can verify redirect app specifies matches app allows.

if visit https://developers.google.com/api-client-library/java/apis/youtube/v3 can generate sample application that's based directly off app in console, in (again) getredirecturi method overwritten use specific callbacks.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -