Is chrome.identity.onSignInChanged available for extensions? Getting an error.. how can I uniquely identify logged in user?

896 views
Skip to first unread message

Sean Anderson

unread,
Oct 21, 2013, 9:46:50 PM10/21/13
to chromium-...@chromium.org
Heya,

I'm looking into using the chrome.identity API for my extension: http://developer.chrome.com/extensions/identity.html

At the bottom, it indicates that their should be a method, chrome.identity.onSignInChanged.addListener(function callback), but I'm getting undefined when I try it: http://i.imgur.com/sw6x136.png and it doesn't look like it is there.

    console.log("Identity:", chrome.identity);
    chrome.identity.onSignInChanged.addListener(function (account, signedIn) {
        console.log("HELLO:", account, signedIn);
    });

with identity requested in the permissions.

Either way, I'm wondering if it is possible to uniquely identify users signed into chrome who are using my extension. It looks like the account object returned from onSignInChanged is what I'm looking for -- something provided by Google and not generated by me and stored in localStorage.

Thanks

Sean

Sean Anderson

unread,
Oct 22, 2013, 12:06:33 AM10/22/13
to chromium-...@chromium.org
Just to build on my last post, I have two code examples to provide you all. One works and one doesn't. The one which does not work is my preferred way of going about things and I would like to understand why it doesn't work.

Here's the non-working example: https://gist.github.com/MeoMix/6ff07fecac68f5927006

I have provided the following in my manifest.json:

"oauth2": {
"client_id": "{CLIENT ID}.apps.googleusercontent.com",
"scopes": [
]
    },
"permissions": [
"identity"
]

where {CLIENT ID} corresponds to a registered app on the platform 'Chrome' 

I receive an error message indicated that my usage limit has been exceeded for a non-authorized user.

However, using the following code sample DOES work: https://gist.github.com/MeoMix/fc3cc53e24794734c2fb

Here I am going through gapi.auth.authorize instead of chrome.identity.

Does anyone have an example where I use the auth token provided by chrome.identity.getAuthToken to interact with the google plus API?

Thanks

Sean


Michael Courage

unread,
Oct 22, 2013, 3:53:21 PM10/22/13
to Sean Anderson, Chromium-extensions
The Identity API sample does a basic request to the plus API: https://github.com/GoogleChrome/chrome-app-samples/tree/master/identity. It's an App, but the API is the same for extensions.

Make sure that the app ID of the extension loaded in Chrome matches the app ID you entered into the dev console when you created your client ID.


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/c5608401-32d0-47d2-918a-aa52d436dc2a%40chromium.org.

Reply all
Reply to author
Forward
0 new messages