rohe
rohe

Reputation: 15

Retrieving chromebook user email in extension

I have a chrome extension installed on a Chromebook. I'm looking for a way for that extension to retrieve the email address with which I'm currently signed into the Chromebook. I tried using the following:

chrome.identity.getProfileUserInfo(function(userInfo){
    console.log(userInfo.email);
});

However it's always empty.

Thanks!

Upvotes: 0

Views: 162

Answers (1)

Marco Bonelli
Marco Bonelli

Reputation: 69346

As stated in this answer, to use the new chrome.identity.getProfileUserInfo API you'll need to request the permission for "identity.email" in your manifest.

So first of all add it to your manifest.json:

"permissions": {
    ...
    "identity.email"
    ...
}

Then you can call the method as you wanted:

chrome.identity.getProfileUserInfo(function(info) {
    console.log(info);
});

// {email: "[email protected]", id: xxxxxx}

Upvotes: 2

Related Questions