Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome Extension with OAuth

I am trying to integrate OAuth with my chrome extension. I am following the tutorial by google: https://developer.chrome.com/extensions/tut_oauth.html

I create ExOauth from the background.js (defined by me and it is loaded by background.html).

var oauth = ChromeExOAuth.initBackgroundPage({
    'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
    'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
    'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
    'consumer_key': 'anonymous',
    'consumer_secret': 'anonymous',
    'scope': 'https://docs.google.com/feeds/',
    'app_name': Test app'
  });

 oauth.authorize(onAuthorized);

Here is the OnAuthorized method:

onAuthorized = function () {
    // Start my application logic.
};

Am I missing something here? When I load the extension, it opens up several "Redirecting...." tabs. Multiple Oauth tabs

like image 900
ssk Avatar asked Jun 21 '13 16:06

ssk


People also ask

How do I add OAuth extension to Chrome?

# Create OAuth client ID Once ready, select Credentials in the sidebar, click Create credentials and choose OAuth client ID. On the Create client ID page, select Chrome App. Fill out the name of the extension and place the extension ID at the end of the URL in the Application ID field. Finish by clicking create.

Is OAuth and autho same?

OAuth 2.0 is a standardized authorization protocol, Auth0 is a company that sells an identity management platform with authentication and authorization services that implements the OAuth2 protocol (among others). Save this answer.

Is OAuth Google free?

It is not free.


1 Answers

The tutorial seems to be missing one file. If you open chrome_ex_oauth.html, you'll see that it tries to load 3 js files:

<script type="text/javascript" src="chrome_ex_oauthsimple.js"></script>
<script type="text/javascript" src="chrome_ex_oauth.js"></script>
<script type="text/javascript" src="onload.js"></script>

The onload.js file is not provided. The OAuth contacts example provides such a file, with the following content:

window.onload = function() {
     ChromeExOAuth.initCallbackPage();
}

After adding this file, it seems to work just fine.

like image 140
Métoule Avatar answered Sep 30 '22 13:09

Métoule