OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

OAuth2 request failed: Service responded with error: 'invalid scope: https://graph.microsoft.com/User.Read

  • Thread starter Thread starter Fuzail Mirza
  • Start date Start date
F

Fuzail Mirza

Guest
So basically , I am building a Chrome Extension using vanilla javascript for outlook. In that extension I have to fetch the email of currently logged in user. I have registered my app on Azure , got the client ID , added the neccessary permissions like openId , profile , User.Read , User.Mail in app , added neccessary scopes but Still I am not getting the identity token.

**

manifest.json**

Code:
{
    "manifest_version": 3,
    "name": "Plugin for Outlook",
    "description": "Base Level Extension",
    "version": "1.0",
    "action": {
      "default_popup": "popup/popup.html",
      "default_icon": "images/logo.png"
    },
    "permissions": [
      "contextMenus",
      "activeTab",
      "scripting",
      "storage",
      "identity"
      
    ],
    "host_permissions": [
      "https://graph.microsoft.com/*",
      "https://ccqrs034g7.execute-api.us-east-1.amazonaws.com/*"
    ],

    "background": {
        "service_worker": "background.js"
      },
      "oauth2": {
        "client_id":"my id",
        "scopes": [
          "openid", "email", "profile" , "https://graph.microsoft.com/profile" 
     ]
      },
    "content_scripts":[
        {
          "matches": ["<all_urls>"],
            "js":["contentScript.js"] 
        }
    ]
  }

background.js

Code:
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  console.log("hello");

  if (message.action === "getEmail") {
    chrome.identity.getAuthToken({ interactive: true }, function (token) {
      if (chrome.runtime.lastError || !token) {
        console.error(chrome.runtime.lastError);
        return;
      }

      fetch("https://graph.microsoft.com/v1.0/me", {
        headers: {
          Authorization: "Bearer " + token,
        },
      })
        .then((response) => response.json())
        .then((userInfo) => {
          const data = message.data;
          console.log(data);

          // Sending Data to backend
         
        })
        .catch((error) => console.error(error));
    });
  }
  return true;
});

<p>So basically , I am building a Chrome Extension using vanilla javascript for outlook. In that extension I have to fetch the email of currently logged in user. I have registered my app on Azure , got the client ID , added the neccessary permissions like openId , profile , User.Read , User.Mail in app , added neccessary scopes but Still I am not getting the identity token.</p>
<p>**</p>
<p>manifest.json**</p>
<pre><code>{
"manifest_version": 3,
"name": "Plugin for Outlook",
"description": "Base Level Extension",
"version": "1.0",
"action": {
"default_popup": "popup/popup.html",
"default_icon": "images/logo.png"
},
"permissions": [
"contextMenus",
"activeTab",
"scripting",
"storage",
"identity"

],
"host_permissions": [
"https://graph.microsoft.com/*",
"https://ccqrs034g7.execute-api.us-east-1.amazonaws.com/*"
],

"background": {
"service_worker": "background.js"
},
"oauth2": {
"client_id":"my id",
"scopes": [
"openid", "email", "profile" , "https://graph.microsoft.com/profile"
]
},
"content_scripts":[
{
"matches": ["<all_urls>"],
"js":["contentScript.js"]
}
]
}
</code></pre>
<p><strong>background.js</strong></p>
<pre><code>chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log("hello");

if (message.action === "getEmail") {
chrome.identity.getAuthToken({ interactive: true }, function (token) {
if (chrome.runtime.lastError || !token) {
console.error(chrome.runtime.lastError);
return;
}

fetch("https://graph.microsoft.com/v1.0/me", {
headers: {
Authorization: "Bearer " + token,
},
})
.then((response) => response.json())
.then((userInfo) => {
const data = message.data;
console.log(data);

// Sending Data to backend

})
.catch((error) => console.error(error));
});
}
return true;
});

</code></pre>
 

Latest posts

Top