/// <summary> /// Opens an interactive logon prompt to acquire an authentication token from the Microsoft Live authentication and identity service. /// <para/> /// Returns a `<see cref="Credential"/>` for packing into a basic authentication header; otherwise `<see langword="null"/>`. /// </summary> /// <param name="targetUri"> /// The uniform resource indicator of the resource access tokens are being requested for. /// </param> /// <param name="options"></param> public async Task <Credential> InteractiveLogon(TargetUri targetUri, PersonalAccessTokenOptions options) { BaseSecureStore.ValidateTargetUri(targetUri); try { Token token; if ((token = await Authority.InteractiveAcquireToken( targetUri, ClientId, Resource, new Uri(RedirectUrl), queryParameters: null)) != null) { Trace.WriteLine($"token '{targetUri}' successfully acquired."); return(await GeneratePersonalAccessToken(targetUri, token, options)); } } catch (AuthenticationException exception) { Debug.Write(exception); } Trace.WriteLine($"failed to acquire token for '{targetUri}'."); return(null); }
public async Task <Credential> InteractiveLogon(TargetUri targetUri, bool requestCompactToken) { BaseSecureStore.ValidateTargetUri(targetUri); try { Token token; if ((token = await Authority.InteractiveAcquireToken(targetUri, ClientId, Resource, new Uri(RedirectUrl), null)) != null) { Trace.WriteLine($"token acquisition for '{targetUri}' succeeded."); return(await GeneratePersonalAccessToken(targetUri, token, requestCompactToken)); } } catch (AuthenticationException) { Trace.WriteLine($"token acquisition for '{targetUri}' failed."); } Trace.WriteLine($"interactive logon for '{targetUri}' failed"); return(null); }