/// <summary>
        /// Acquires security token from the authority.
        /// </summary>
        /// <remarks>This feature is supported only for Azure Active Directory and Active Directory Federation Services (ADFS) on Windows 10.</remarks>
        /// <param name="ctx">Authentication context instance</param>
        /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
        /// <param name="clientId">Identifier of the client requesting the token.</param>
        /// <param name="userCredential">The user credential to use for token acquisition.</param>
        /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
        public static async Task <AuthenticationResult> AcquireTokenAsync(this AuthenticationContext ctx, string resource, string clientId, UserCredential userCredential)
        {
            HttpMessageHandlerFactory.UpdateWebProxyNeeded += (sender, args) =>
            {
                args.HttpClient.Proxy = new WebProxy(args.ProxyUrl, true)
                {
                    UseDefaultCredentials = true
                };
            };

            return(await ctx.AcquireTokenCommonAsync(resource, clientId, userCredential).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Acquires security token from the authority.
 /// </summary>
 /// <param name="ctx">Authentication context instance</param>
 /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
 /// <param name="clientId">Identifier of the client requesting the token.</param>
 /// <param name="userAssertion">The assertion to use for token acquisition.</param>
 /// <returns>It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.</returns>
 public static async Task <AuthenticationResult> AcquireTokenAsync(this AuthenticationContext ctx,
                                                                   string resource, string clientId,
                                                                   UserAssertion userAssertion)
 {
     return(await ctx.AcquireTokenCommonAsync(resource, clientId, userAssertion).ConfigureAwait(false));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Acquires security token from the authority.
 /// </summary>
 /// <remarks>This feature is supported only for Azure Active Directory and Active Directory Federation Services (ADFS) on Windows 10.</remarks>
 /// <param name="ctx">Authentication context instance</param>
 /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
 /// <param name="clientId">Identifier of the client requesting the token.</param>
 /// <param name="userCredential">The user credential to use for token acquisition.</param>
 /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
 public static async Task <AuthenticationResult> AcquireTokenAsync(this AuthenticationContext ctx, string resource, string clientId, UserCredential userCredential)
 {
     return(await ctx.AcquireTokenCommonAsync(resource, clientId, userCredential));
 }