Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct redirect URI for Google API and OAuth 2.0

I am making an application with the Google Maps API. I want to be able to have one person on a computer, watch what another person has edited to a map. I am thinking of passing information of the map to a Google Fusion Table. The other person will be able to see everything as a layer. I would like for the program to just run from the user's browser and not build a website for it.

To edit the fusion tables, I need to gain access/tokens. I am currently trying to use these there JavaScript to accomplish this. ScriptSample.html, oauthWindow.html, and gwt-oauth2.js. This is the working example.

When I run them, I get am error that says the redirect URI is incorrect. It says the file I use to redirect does not have authority. My first obvious question is:

How do I give that file authority to redirect?

In my API console, I have it set up as a client-side web application. Should I change it to an installed application?

Currently I have the following settings:

  • my JavaScript origin is: https://localhost
  • redirect URI: https://localhost/oauthWindow.html

Thanks

like image 795
user1454212 Avatar asked Jul 04 '12 14:07

user1454212


People also ask

What is redirect URI in oauth2 Google?

The redirect URIs are the endpoints to which the OAuth 2.0 server can send responses. These endpoints must adhere to Google's validation rules. For testing, you can specify URIs that refer to the local machine, such as http://localhost:8080 .

What should be the redirect URI in oauth2?

A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.


1 Answers

There's no problem with using a localhost url for Dev work - obviously it needs to be changed when it comes to production.

You need to go here: https://developers.google.com/accounts/docs/OAuth2 and then follow the link for the API Console - link's in the Basic Steps section. When you've filled out the new application form you'll be asked to provide a redirect Url. Put in the page you want to go to once access has been granted.

When forming the Google oAuth Url - you need to include the redirect url - it has to be an exact match or you'll have problems. It also needs to be UrlEncoded.

like image 186
Swomble Avatar answered Sep 24 '22 00:09

Swomble