"microsoftTeams.authentication.getAuthToken" Failed
I developed a web page hosted in teams app, need to authentication in web.
microsoftTeams.app.initialize().then(() => {
microsoftTeams.authentication.getAuthToken().then((result) => {
resolve(result);
}).catch((error) => {
reject("Error getting token: " + error);
});
});
In manifest.json, I configure
"webApplicationInfo": {
"id": "${{AAD_APP_CLIENT_ID}}",
"resource": "api://${{TAB_DOMAIN}}/${{AAD_APP_CLIENT_ID}}"
}
I open the web in teams app:
The result I get is
{"Description":"Recieved an error from AAD. Code: 'invalid_resource' description: '(pii)' correlation id: 'b23ed14c-137a-400e-98c0-d9969662ab1a'","Domain":"com.microsoft.oneauth","ErrorCode":"2002","Message":"Access denied for the resource.","SystemErrorCode":"0","Tag":"965yc","Type":"OneAuth","aad_request_sequence":"1.P","additional_query_parameters_count":"2","all_error_tags":"965yc|965yc|965yc","api_error_code":"0","api_error_context":"Recieved an error from AAD. Code: 'invalid_resource' description: '(pii)' correlation id: 'b23ed14c-137a-400e-98c0-d9969662ab1a'","api_error_tag":"965yc","api_name":"AcquireTokenSilently","api_status_code":"StatusInternal::IncorrectConfiguration","auth_flow":"FRT","auth_flow_last_error":"invalid_resource","authority_type":"AAD","authorization_type":"CachedRefreshToken","broker_app_used":"false","client_id":"1fec8e78-bce4-4aaf-ab1b-5451cc387264","correlation_id":"b23ed14c-137a-400e-98c0-d9969662ab1a","http_call_count":"1","is_successful":"false","last_http_response_code":"400","msal_version":"1.1.0+61e1eea1","original_authority":"https://login.microsoftonline.com/270a8c96-4480-4b5c-954f-c264cee2d33c","prt_enabled":"false","read_token":"ID|ART-8f09e19b2bd57f78|FRT-8f09e19b2bd57f78","request_duration":"558","request_eligible_for_broker":"false-SsoUnavbl","request_id":"a11b7dc0-8afe-40e4-ae1b-6869e0089b01","request_new_prt":"false","server_error_code":"500011","start_time":"2025-02-10T10:24:41.000Z","stop_time":"2025-02-10T10:24:41.000Z","storage_read":"DAC|DID|DAMD|DRT|DRT","was_request_throttled":"false”}