/// <summary> /// Exchange authentication code for access token. /// </summary> /// <param name="context">The HttpContextBase instance</param> /// <param name="redirectUri">The redirect URL of the app.</param> /// <returns>An async Task instance.</returns> public Task <LiveLoginResult> ExchangeAuthCodeAsync( HttpContextBase context, string redirectUrl) { LiveUtility.ValidateNotNullParameter(context, "context"); if (string.IsNullOrWhiteSpace(redirectUrl)) { redirectUrl = LiveAuthUtility.GetCurrentRedirectUrl(context.Request.Url); } else { LiveUtility.ValidateUrl(redirectUrl, "redirectUrl"); } return(this.authClient.ExchangeAuthCodeAsync(redirectUrl, context)); }
/// <summary> /// Initializes the LiveAuthClient instance for the current user. /// If an authorization code is present, it will send a request to the auth server to exchange the token. /// If there is an auth session in current context, it will retrieve the current auth session. /// If the current session is expired or the current request url indicates (refresh=1) to get a new token, /// it will try to request a new access token using refresh token that will need to be provided through /// IRefreshTokenHandler.RetrieveRefreshTokenAsync() method. /// Any updated session state will be saved in the auth session cookie. /// </summary> /// <param name="context">The HttpContextBase instance of current request.</param> /// <param name="redirectUrl">The redirect URL of the app. This must match exactly the Url that is used to /// generate the login Url via LiveAuthClient.GetLoginUrl</param> /// <param name="scopes">A list of scopes to validate whether the user has consented. If the available session /// does not satisfy the specified scopes, NotConnected status will be returned. However, the developer still /// can find the available session throw the Session property.</param> /// <returns>An async Task instance</returns> public Task <LiveLoginResult> InitializeWebSessionAsync( HttpContextBase context, string redirectUrl, IEnumerable <string> scopes) { LiveUtility.ValidateNotNullParameter(context, "context"); if (string.IsNullOrWhiteSpace(redirectUrl)) { redirectUrl = LiveAuthUtility.GetCurrentRedirectUrl(context.Request.Url); } else { LiveUtility.ValidateUrl(redirectUrl, "redirectUrl"); } return(this.authClient.InitializeWebSessionAsync(redirectUrl, context, scopes)); }