public AuthenticationResult( string accessToken, bool isExtendedLifeTimeToken, string uniqueId, DateTimeOffset expiresOn, DateTimeOffset extendedExpiresOn, string tenantId, IAccount account, string idToken, IEnumerable <string> scopes, Guid correlationId, AuthenticationResultMetadata authenticationResultMetadata, string tokenType = "Bearer") : this( accessToken, isExtendedLifeTimeToken, uniqueId, expiresOn, extendedExpiresOn, tenantId, account, idToken, scopes, correlationId, tokenType, authenticationResultMetadata) { }
/// <summary> /// Constructor meant to help application developers test their apps. Allows mocking of authentication flows. /// App developers should <b>never</b> new-up <see cref="AuthenticationResult"/> in product code. /// </summary> /// <param name="accessToken">Access Token that can be used as a bearer token to access protected web APIs</param> /// <param name="account">Account information</param> /// <param name="expiresOn">Expiry date-time for the access token</param> /// <param name="extendedExpiresOn">See <see cref="ExtendedExpiresOn"/></param> /// <param name="idToken">ID token</param> /// <param name="isExtendedLifeTimeToken">See <see cref="IsExtendedLifeTimeToken"/></param> /// <param name="scopes">Granted scope values as returned by the service</param> /// <param name="tenantId">Identifier for the Azure AD tenant from which the token was acquired. Can be <c>null</c></param> /// <param name="uniqueId">Unique Id of the account. It can be null. When the <see cref="IdToken"/> is not <c>null</c>, this is its ID, that is its ObjectId claim, or if that claim is <c>null</c>, the Subject claim.</param> /// <param name="correlationId">The correlation id of the authentication request</param> /// <param name="tokenType">The token type, defaults to Bearer. Note: this property is experimental and may change in future versions of the library.</param> /// <param name="authenticationResultMetadata">Contains metadata related to the Authentication Result.</param> public AuthenticationResult( // for backwards compat with 4.16- string accessToken, bool isExtendedLifeTimeToken, string uniqueId, DateTimeOffset expiresOn, DateTimeOffset extendedExpiresOn, string tenantId, IAccount account, string idToken, IEnumerable <string> scopes, Guid correlationId, string tokenType = "Bearer", AuthenticationResultMetadata authenticationResultMetadata = null) { AccessToken = accessToken; IsExtendedLifeTimeToken = isExtendedLifeTimeToken; UniqueId = uniqueId; ExpiresOn = expiresOn; ExtendedExpiresOn = extendedExpiresOn; TenantId = tenantId; Account = account; IdToken = idToken; Scopes = scopes; CorrelationId = correlationId; TokenType = tokenType; AuthenticationResultMetadata = authenticationResultMetadata; }
internal AuthenticationResult( MsalAccessTokenCacheItem msalAccessTokenCacheItem, MsalIdTokenCacheItem msalIdTokenCacheItem, IAuthenticationScheme authenticationScheme, Guid correlationID, TokenSource tokenSource, ApiEvent apiEvent, Account account, string spaAuthCode = null) { _authenticationScheme = authenticationScheme ?? throw new ArgumentNullException(nameof(authenticationScheme)); string homeAccountId = msalAccessTokenCacheItem?.HomeAccountId ?? msalIdTokenCacheItem?.HomeAccountId; string environment = msalAccessTokenCacheItem?.Environment ?? msalIdTokenCacheItem?.Environment; ClaimsPrincipal = msalIdTokenCacheItem?.IdToken.ClaimsPrincipal; if (account != null) { Account = account; } else if (homeAccountId != null) { Account = new Account( homeAccountId, msalIdTokenCacheItem?.GetUsername(), environment); } UniqueId = msalIdTokenCacheItem?.IdToken?.GetUniqueId(); TenantId = msalIdTokenCacheItem?.IdToken?.TenantId; IdToken = msalIdTokenCacheItem?.Secret; SpaAuthCode = spaAuthCode; CorrelationId = correlationID; ApiEvent = apiEvent; AuthenticationResultMetadata = new AuthenticationResultMetadata(tokenSource); if (msalAccessTokenCacheItem != null) { AccessToken = authenticationScheme.FormatAccessToken(msalAccessTokenCacheItem); ExpiresOn = msalAccessTokenCacheItem.ExpiresOn; ExtendedExpiresOn = msalAccessTokenCacheItem.ExtendedExpiresOn; Scopes = msalAccessTokenCacheItem.ScopeSet; IsExtendedLifeTimeToken = msalAccessTokenCacheItem.IsExtendedLifeTimeToken; TokenType = msalAccessTokenCacheItem.TokenType; if (msalAccessTokenCacheItem.RefreshOn.HasValue) { AuthenticationResultMetadata.RefreshOn = msalAccessTokenCacheItem.RefreshOn; } } }
internal AuthenticationResult( MsalAccessTokenCacheItem msalAccessTokenCacheItem, MsalIdTokenCacheItem msalIdTokenCacheItem, IAuthenticationScheme authenticationScheme, Guid correlationID, TokenSource tokenSource, ApiEvent apiEvent) { _authenticationScheme = authenticationScheme ?? throw new ArgumentNullException(nameof(authenticationScheme)); string homeAccountId = msalAccessTokenCacheItem?.HomeAccountId ?? msalIdTokenCacheItem?.HomeAccountId; string environment = msalAccessTokenCacheItem?.Environment ?? msalIdTokenCacheItem?.Environment; if (homeAccountId != null) { string username = null; if (msalIdTokenCacheItem != null) { username = msalIdTokenCacheItem.IsAdfs ? msalIdTokenCacheItem?.IdToken.Upn : msalIdTokenCacheItem?.IdToken?.PreferredUsername; } Account = new Account( homeAccountId, username, environment); } if (msalAccessTokenCacheItem != null) { AccessToken = authenticationScheme.FormatAccessToken(msalAccessTokenCacheItem); ExpiresOn = msalAccessTokenCacheItem.ExpiresOn; ExtendedExpiresOn = msalAccessTokenCacheItem.ExtendedExpiresOn; Scopes = msalAccessTokenCacheItem.ScopeSet; IsExtendedLifeTimeToken = msalAccessTokenCacheItem.IsExtendedLifeTimeToken; TokenType = msalAccessTokenCacheItem.TokenType; } UniqueId = msalIdTokenCacheItem?.IdToken?.GetUniqueId(); TenantId = msalIdTokenCacheItem?.IdToken?.TenantId; IdToken = msalIdTokenCacheItem?.Secret; CorrelationId = correlationID; ApiEvent = apiEvent; AuthenticationResultMetadata = new AuthenticationResultMetadata(tokenSource); }