'find the logged in gmail user email address
I am working on chrome extension which is focused only for gmail messages. The extension is used only in the gmail messages but for this i need to find out the logged in users email address. I have created the login functionality to use the extension in the popup and I need "logged in users email address" to check if the user that is logging in the extension matches with that email address or not.
I tried two things in the background script(background.js).
chrome.cookies.getAll({ domain: 'accounts.google.com' }, function(cookies) {
console.log('accounts.google.com cookies', cookies);
});
chrome.identity.getProfileUserInfo(function(profile) {
console.log('profile', profile);
});
1st method gives me an empty array
2nd method gives me an object of empty email and id
Can anyone help me in providing the reliable solution for finding the logged in user's email address, please?
UPDATE
I found that chrome.identity.getProfileUserInfo(function(profile) { this gives me the email that is registered in chrome not of the logged in gmail email address.
Solution 1:[1]
Add Permissions "identity.email" and "cookies" in manifest.json.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gokulnath |
