AcquireTokenSilent immer Versagt zu erwerben token leise

Verwendung von ADAL ich habe zwei AuthenticationContext mit einem Token-Cache persistiert in SQL.

Mit AcquireTokenByAuthorizationCode schreibt er das Token in der Datenbank, aber bei der Verwendung von AcquireTokenSilent ich bekomme immer

Fehlgeschlagen zu erwerben token leise. Call method AcquireToken

Hier sind die details für die Replikation das Problem:

Ich einen Kontext schaffen, in

AuthenticationContext authContext = new AuthenticationContext(_authority, new AzureAdalCache(companyId, _entries, _unitOfWork));

Dann Habe Ich AcquireToken Von Der Autorisierung

authContext.AcquireTokenByAuthorizationCode(authorizationCode, new Uri(redirectUri), _clientCredential);

Zu diesem Zeitpunkt speichert ein Eintrag in der Datenbank

Dann wenn ich den Anruf das ich eine Ausnahme.

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

Ich habe auch versucht mit dem gleichen Ergebnis:

authContext.AcquireTokenSilent(_authority, _clientId).AccessToken;
authContext.AcquireTokenSilent(_authority, _clientCredential, UserIdentifier.AnyUser).AccessToken;

Poste ich mein AzureAdalCache Umsetzung in diese Gist.

Jeder Eintrag der Cache ist wie diese.

Was Bin ich?

Update

Basiert auf Antworten von Kommentaren von @vibronet ich habe diese

AuthenticationContext authContext = new AuthenticationContext(_authority, new AzureAdalCache(companyId, _entries, _unitOfWork));
authContext.AcquireTokenByAuthorizationCode(authorizationCode, new Uri(redirectUri), _clientCredential, _eWSResource);
string result = authContext.AcquireTokenSilent(_eWSResource, _clientId, UserIdentifier.AnyUser).AccessToken;

InformationsquelleAutor Ricardo Polo | 2015-04-20

Schreibe einen Kommentar