Added an example using the identity API (#180)

* Added an example using the identity API

* Updated with review comment fixes
This commit is contained in:
wbamberg
2017-02-16 12:02:10 -08:00
committed by GitHub
parent 39cd28eb2b
commit 4474a6bd4b
10 changed files with 214 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
function notifyUser(user) {
browser.notifications.create({
"type": "basic",
"title": "Google info",
"message": `Hi ${user.name}`
});}
function logError(error) {
console.error(`Error: ${error}`);
}
/**
When the button's clicked:
- get an access token using the identity API
- use it to get the user's info
- show a notification containing some of it
*/
browser.browserAction.onClicked.addListener(() => {
getAccessToken()
.then(getUserInfo)
.then(notifyUser)
.catch(logError);
});