Redirect_uri_mismatch when accessing the Google API using OAuth2

I am creating a mobile application using Sencha Touch and PhoneGap. I want users to be able to log into the application using their Google credentials, but I hit a brick wall with an initial request with the following error:

The redirect URI in the request: http: // localhost does not match the registered URI.

My Google API account has default registered URIs ( http: // localhost and urn: ietf: wg: oauth: 2.0: oob).

I tried both of them without success.

The sent request contains the following query string parameters:

The main process:

  • build url as above
  • open a new browser window (using the ChildBrowser PhoneGap module)
  • go to url
  • at this point the Google login page is displayed and allows me to enter credentials
  • after logging in, I got to the error page containing the above error.

I am testing this on the iPhone simulator and on my iPhone with the same result in both. The application does not start on http: // localhost , but in the file: /// var / mobile / Applications / <guid> / <app name> /www/index.html, but there is no way to add this to the Google Console (..or there is?:))

- - , ? OAuth API Google, !

+5
3

Google API OAuth2, : OAuth2 .

, , , :

https://accounts.google.com/o/oauth2/device/code

curl ( API Google+):

curl https://accounts.google.com/o/oauth2/device/code -d "client_id=**your_client_id**" -d "scope=https://www.googleapis.com/auth/plus.me" -d "redirect_uri=urn:ietf:wg:oauth:2.0:oob"

:

{
  "device_code" : "4/AToZcyQ7U1BTV-xu4LAqpw02SgIW",
  "user_code" : "bqsj67hb",
  "verification_url" : "http://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

, user_code verify_url "" . :

, user_code verify_url, Google device_code, user_code verify_url. URL- https://accounts.google.com/o/oauth2/token, .

access_token, curl:

curl https://accounts.google.com/o/oauth2/token -d "client_id=**your_client_id**&client_secret=**your_client_secret**&code=**the _device_code_obtained_before**&grant_type=http://oauth.net/grant_type/device/1.0" 

:

{
  "access_token" : "y23r9.AHES6ZT78qJl14pTueruthfh5676TYDF234-Eme33iQ",
  "token_type" : "Bearer",
  "expires_in" : 3600,
  "id_token" :  "eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXVkIjoiNzgyMTM3OTUzMjkwLmFwcHMuZ29vZ2iLCJ0b2tlbl9oYXNoIjoiUUt0YmxTZUdsRUdNOVdPcUliRGR2QSIsImlhdCI6MTMzNDE3MDI1NywiZXhwIjoxMzM0MTc0MTU3fQ.Iz_Sv9X2fCydj4VfEdDxwWVH70DEK-rSzA5pWV9bvBdYB5VwgwFd8CSnotesDzJxq5pSKGwnAgvBfxSUbuGVmdET3E2sbrLODKymO9FoBzenfVooCwRXurzxvjKWF1EL3007lOPzTx9UGjqwShjjKQRoNjLFs-OmGCJsZGTHTGE",
  "refresh_token" : "1/gjgpKUyppp223s43HMerTX-zS_2JUxQOCk"
}

, , ( API, API Google+) access_token.

curl https://www.googleapis.com/plus/v1/people/me?access_token=y23r9.AHES6ZT78qJl14pTueruthfh5676TYDF234-Eme33iQ

" http://localhost url ".

, . redirect_uri , . .

"urn: ietf: wg: oauth: 2.0: oob" . "" "" , , this.

!

+8

, . redirect_url_mismatch, , URL- Google Cloud Console. URL , http://localhost:8080 http://localhost:8080/.

, ( client_id). redirect_uri , ; , localhost:8080. , , .

+1

, : API - . , URL http:// uri. URL- Apache:

<? header("Location:myapp://authorize?code=".$_GET['code']); ?>

, OAuth, facebook...

0

All Articles