Tran B. V. Son
Tran B. V. Son

Reputation: 839

Can't find Grant Admin Consent

I'm making a function that gets new access token by refresh token,

const getAccessToken = async refreshToken => {
  try {
    const accessTokenObj = await axios.post(
      'https://login.microsoftonline.com/common/oauth2/token',
      querystring.stringify({
        refresh_token: refreshToken,
        client_id: 'xxxxx',
        client_secret: 'xxxxx',
        grant_type: 'refresh_token',
        resource: 'https://graph.microsoft.com',
        prompt: 'admin_consent'
      })
    );
    return accessTokenObj;
  } catch (err) {
    console.log(err);
  }
};

but when I run my code, I got this error:

The user or administrator has not consented to use the application with ID 'xxxxx' named 'xxxxx'. Send an interactive authorization request for this user and resource.

So I was following this tutorial to grant admin consent by I couldn't find Grant Admin Consent button in my application.

a busy cat

What I was missing? I'm using a personal account to create an application.

Upvotes: 2

Views: 633

Answers (1)

Md Farid Uddin Kiron
Md Farid Uddin Kiron

Reputation: 22429

You could follow below steps:

enter image description here

Note: With personal account you cannot get Grant Consent Option. you should have tenant account. After that you can add Personal account for that operation. Better you can try with dedicated permission

Upvotes: 1

Related Questions