AcquireTokenSilent always Failed to acquire token silently

后端 未结 5 675
清酒与你
清酒与你 2021-01-04 04:16

Using ADAL I have two AuthenticationContext using a Token Cache persisted in SQL.

Using AcquireTokenByAuthorizationCode it writes the Token

5条回答
  •  轮回少年
    2021-01-04 04:44

    I don't understand the call:

    authContext.AcquireTokenSilent(
        _authority,
        _clientCredential,
        new UserIdentifier(companyId.ToString(), UserIdentifierType.UniqueId)
    ).AccessToken;
    

    The UserIdentifier must match the value in the cache, and CompanyID does not sound like any of the identifier you get back for the token.

    Please take a look at the sample I pointed you to on the other thread, and specifically on the identifier used in call to AcquireTokenSilent in https://github.com/AzureADSamples/WebApp-WebAPI-OpenIDConnect-DotNet/blob/master/TodoListWebApp/Controllers/TodoListController.cs

    You don't get to choose which identifier to use in that call, that is determined by what claims AAD issues. The only identifiers you can choose are at the cache instance level, not in individual AcquireToken* calls.

提交回复
热议问题