Partner-Center-PowerShell
Partner-Center-PowerShell copied to clipboard
New-PartnerAccessToken for Connect-AzAccount AADSTS65001: The user or administrator has not consented to use the application
Steps to reproduce
I am using an account with MFA enabled to get the Refreshtoken. The Account is an admin agent and the app has the following permissions:

Just a snippet of my reproduction script:
Everything seems to work until I try to grab the $azureToken.
$token = New-PartnerAccessToken -ApplicationId $cspappid -Scopes 'https://api.partnercenter.microsoft.com/user_impersonation' -ServicePrincipal -Credential $credential -Tenant $tenantid -UseAuthorizationCode
$refreshToken = $token.RefreshToken
$token = New-PartnerAccessToken -ApplicationId $cspappid -Credential $credential -RefreshToken $refreshToken -Scopes "https://api.partnercenter.microsoft.com/user_impersonation" -ServicePrincipal -Tenant $CSPTenantID
Connect-PartnerCenter -ApplicationId $cspappid -Credential $credential -RefreshToken $refreshToken
$aadGraphToken = New-PartnerAccessToken -ApplicationId $cspappid -Credential $credential -RefreshToken $refreshToken -Scopes 'https://graph.windows.net/.default' -ServicePrincipal -Tenant $CustomerTenantID
$azureToken = New-PartnerAccessToken -ApplicationId $cspappid -Credential $credential -RefreshToken $refreshToken -Scopes 'https://management.azure.com/user_impersonation' -ServicePrincipal -Tenant $CustomerTenantID
$graphToken = New-PartnerAccessToken -ApplicationId $cspappid -Credential $credential -RefreshToken $refreshToken -Scopes 'https://graph.windows.net/.default' -ServicePrincipal -Tenant $CustomerTenantID
Expected behavior
Grab the Azure Token
Actual behavior
New-PartnerAccessToken: AADSTS65001: The user or administrator has not consented to use the application with ID 'yyyy-yyyy-yyyy-yyyy' named 'PartnerCenter App'. Send an interactive authorization request for this user and resource.
Diagnostic logs
Please share test platform diagnostics logs.
The logs may contain test assembly paths, kindly review and mask those before sharing.
Environment
Please share additional details about your environment. Version