public async Task <string> GetAuthorizationCodeAsync( string clientId, string returnUrl, string[] scopes, IWebAuthenticationUi webAuthenticationUi, string userId = null) { if (webAuthenticationUi != null) { var requestUri = new Uri( this.GetAuthorizationCodeRequestUrl( clientId, returnUrl, scopes, userId)); var authenticationResponseValues = await webAuthenticationUi.AuthenticateAsync( requestUri, new Uri(returnUrl)).ConfigureAwait(false); OAuthErrorHandler.ThrowIfError(authenticationResponseValues); string code; if (authenticationResponseValues != null && authenticationResponseValues.TryGetValue("code", out code)) { return(code); } } return(null); }
private AdalAuthenticationProvider( string clientId, string clientSecret, X509Certificate2 clientCertificate, string returnUrl, AuthenticationContext authenticationContext) : base(clientId, returnUrl, authenticationContext) { this.clientSecret = clientSecret; this.clientCertificate = clientCertificate; this.oAuthHelper = new OAuthHelper(); this.webAuthenticationUi = new FormsWebAuthenticationUi(); if (this.clientCertificate != null) { this.AuthenticateUser = this.PromptUserForAuthenticationWithClientCertificateAsync; this.AuthenticateUserSilently = this.SilentlyAuthenticateUserWithClientCertificateAsync; } else if (!string.IsNullOrEmpty(this.clientSecret)) { this.AuthenticateUser = this.PromptUserForAuthenticationWithClientSecretAsync; this.AuthenticateUserSilently = this.SilentlyAuthenticateUserWithClientSecretAsync; } else { this.AuthenticateUser = this.PromptUserForAuthenticationAsync; this.AuthenticateUserSilently = this.SilentlyAuthenticateUserAsync; } }
/// <summary> /// Constructs an <see cref="MsaAuthenticationProvider"/>. /// </summary> public MsaAuthenticationProvider( string clientId, string clientSecret, string returnUrl, string[] scopes, CredentialCache credentialCache) { this.clientId = clientId; this.clientSecret = clientSecret; this.returnUrl = returnUrl; this.scopes = scopes; this.CredentialCache = credentialCache ?? new CredentialCache(); this.oAuthHelper = new OAuthHelper(); this.webAuthenticationUi = new FormsWebAuthenticationUi(); }
/// <summary> /// Creates a OneDrive client for use against OneDrive consumer. /// </summary> /// <param name="appId">The application ID for Microsoft Account authentication.</param> /// <param name="returnUrl">The application return URL for Microsoft Account authentication.</param> /// <param name="scopes">The requested scopes for Microsoft Account authentication.</param> /// <param name="credentialCache">The cache instance for storing user credentials.</param> /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns> public static IOneDriveClient GetMicrosoftAccountClient( string appId, string returnUrl, string[] scopes, CredentialCache credentialCache = null, IHttpProvider httpProvider = null, IWebAuthenticationUi webAuthenticationUi = null) { return OneDriveClient.GetMicrosoftAccountClient( appId, returnUrl, scopes, /* clientSecret */ null, credentialCache, httpProvider, new ServiceInfoProvider(webAuthenticationUi)); }
/// <summary> /// Creates a OneDrive client for use against OneDrive consumer. /// </summary> /// <param name="appId">The application ID for Microsoft account authentication.</param> /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param> /// <param name="scopes">The requested scopes for Microsoft account authentication.</param> /// <param name="credentialCache">The cache instance for storing user credentials.</param> /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns> public static IOneDriveClient GetMicrosoftAccountClient( string appId, string returnUrl, string[] scopes, CredentialCache credentialCache = null, IHttpProvider httpProvider = null, IWebAuthenticationUi webAuthenticationUi = null) { return(OneDriveClient.GetMicrosoftAccountClient( appId, returnUrl, scopes, /* clientSecret */ null, credentialCache, httpProvider, new ServiceInfoProvider(webAuthenticationUi))); }
/// <summary> /// Creates an authenticated OneDrive client for use against OneDrive consumer. /// </summary> /// <param name="appId">The application ID for Microsoft account authentication.</param> /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param> /// <param name="scopes">The requested scopes for Microsoft account authentication.</param> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> /// <param name="credentialCache">The cache instance for storing user credentials.</param> /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param> /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns> public static Task <IOneDriveClient> GetAuthenticatedMicrosoftAccountClient( string appId, string returnUrl, string[] scopes, IWebAuthenticationUi webAuthenticationUi, CredentialCache credentialCache = null, IHttpProvider httpProvider = null) { return(OneDriveClient.GetAuthenticatedMicrosoftAccountClient( appId, returnUrl, scopes, /* clientSecret */ null, webAuthenticationUi, credentialCache, httpProvider)); }
/// <summary> /// Creates an authenticated OneDrive client for use against OneDrive consumer. /// </summary> /// <param name="appId">The application ID for Microsoft account authentication.</param> /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param> /// <param name="scopes">The requested scopes for Microsoft account authentication.</param> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> /// <param name="credentialCache">The cache instance for storing user credentials.</param> /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param> /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns> public static Task<IOneDriveClient> GetAuthenticatedMicrosoftAccountClient( string appId, string returnUrl, string[] scopes, IWebAuthenticationUi webAuthenticationUi, CredentialCache credentialCache = null, IHttpProvider httpProvider = null) { return OneDriveClient.GetAuthenticatedMicrosoftAccountClient( appId, returnUrl, scopes, /* clientSecret */ null, webAuthenticationUi, credentialCache, httpProvider); }
/// <summary> /// Constructs an <see cref="MsaAuthenticationProvider"/>. /// </summary> internal MsaAuthenticationProvider( string clientId, string clientSecret, string returnUrl, string[] scopes, CredentialCache credentialCache, IWebAuthenticationUi authenticationUi) { this.clientId = clientId; this.clientSecret = clientSecret; this.returnUrl = returnUrl; this.scopes = scopes; this.CredentialCache = credentialCache ?? new CredentialCache(); this.oAuthHelper = new OAuthHelper(); this.webAuthenticationUi = authenticationUi; }
/// <summary> /// Constructs an <see cref="MsaAuthenticationProvider"/>. /// </summary> public MsaAuthenticationProvider( string clientId, string returnUrl, string[] scopes, CredentialCache credentialCache) { this.clientId = clientId; this.clientSecret = null; this.returnUrl = string.IsNullOrEmpty(returnUrl) ? WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString() : returnUrl; this.scopes = scopes; this.CredentialCache = credentialCache ?? new CredentialCache(); this.oAuthHelper = new OAuthHelper(); this.webAuthenticationUi = new WebAuthenticationBrokerWebAuthenticationUi(); }
public void CopyFrom(ServiceInfo serviceInfo) { this.AccountType = serviceInfo.AccountType; this.AppId = serviceInfo.AppId; this.AuthenticationProvider = serviceInfo.AuthenticationProvider; this.AuthenticationServiceUrl = serviceInfo.AuthenticationServiceUrl; this.BaseUrl = serviceInfo.BaseUrl; this.ClientSecret = serviceInfo.ClientSecret; this.CredentialCache = serviceInfo.CredentialCache; this.DiscoveryServiceResource = serviceInfo.DiscoveryServiceResource; this.DiscoveryServiceUrl = serviceInfo.DiscoveryServiceUrl; this.HttpProvider = serviceInfo.HttpProvider; this.MicrosoftAccountPromptType = serviceInfo.MicrosoftAccountPromptType; this.OneDriveServiceEndpointVersion = serviceInfo.OneDriveServiceEndpointVersion; this.ReturnUrl = serviceInfo.ReturnUrl; this.Scopes = serviceInfo.Scopes; this.ServiceResource = serviceInfo.ServiceResource; this.SignOutUrl = serviceInfo.SignOutUrl; this.TokenServiceUrl = serviceInfo.TokenServiceUrl; this.UserId = serviceInfo.UserId; this.WebAuthenticationUi = serviceInfo.WebAuthenticationUi; }
/// <summary> /// Constructs an <see cref="MsaAuthenticationProvider"/>. /// </summary> public MsaAuthenticationProvider( string clientId, string returnUrl, string[] scopes, CredentialCache credentialCache) { this.clientId = clientId; this.clientSecret = null; this.returnUrl = string.IsNullOrEmpty(returnUrl) ? WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString() : returnUrl; this.scopes = scopes; this.CredentialCache = credentialCache ?? new CredentialCache(); this.oAuthHelper = new OAuthHelper(); #if WINRT this.webAuthenticationUi = new WebAuthenticationBrokerWebAuthenticationUi(); #elif WINDOWS_UWP // WebAuthenticationBroker is not supported on Windows 10 IoT Core, so if we're running UWP, // we need to first check if we're running on IoT Core. If we are, we fall back to our // own implementation. // Our method of detection here isn't bulletproof--more non-IoT device families could fall under // this namespace in the future. Unfortunately, using API detection won't work, because the API // is AVAILABLE in IoT, it just doesn't actually work. if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT") { this.webAuthenticationUi = new IotCoreFriendlyWebAuthenticationUi(); } else { this.webAuthenticationUi = new WebAuthenticationBrokerWebAuthenticationUi(); } #endif }
public AdalServiceInfoProvider(IAuthenticationProvider authenticationProvider, IWebAuthenticationUi webAuthenticationUi) : base(authenticationProvider, webAuthenticationUi) { }
/// <summary> /// Instantiates a new <see cref="ServiceInfoProvider"/>. /// </summary> /// <param name="authenticationProvider">The <see cref="IAuthenticationProvider"/> for authenticating the user.</param> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> public ServiceInfoProvider(IAuthenticationProvider authenticationProvider = null, IWebAuthenticationUi webAuthenticationUi = null) { this.AuthenticationProvider = authenticationProvider; this.webAuthenticationUi = webAuthenticationUi; }
public WebAuthenticationBrokerServiceInfoProvider(IWebAuthenticationUi webAuthenticationUi = null) { this.webAuthenticationUi = webAuthenticationUi ?? new WebAuthenticationBrokerWebAuthenticationUi(); }
/// <summary> /// Instantiates a new <see cref="ServiceInfoProvider"/>. /// </summary> /// <param name="webAuthenticationUi">The <see cref="IWebAuthenticationUi"/> for displaying authentication UI to the user.</param> public ServiceInfoProvider(IWebAuthenticationUi webAuthenticationUi) : this(null, webAuthenticationUi) { }
public AdalServiceInfoProvider(IWebAuthenticationUi webAuthenticationUi) : this(null, webAuthenticationUi) { }