예제 #1
0
 /// <summary>
 /// Generates a URL that the user's browser can be directed to in order to authorize
 /// this client to access protected data at some resource server.
 /// </summary>
 /// <param name="authAgentClient">The auth user agent client.</param>
 /// <param name="scopes">The scope of authorized access requested.</param>
 /// <param name="state">The client state that should be returned with the authorization response.</param>
 /// <param name="returnTo">The URL that the authorization response should be sent to via a user-agent redirect.</param>
 public virtual void RequestAgentUserAuthorization(AuthAgentClient authAgentClient = null, string[] scopes = null, string state = null, Uri returnTo = null)
 {
     if (authAgentClient != null)
     {
         authAgentClient.RequestUserAuthorization(scopes, state, returnTo);
     }
     else
     {
         _authAgentClient.RequestUserAuthorization(scopes, state, returnTo);
     }
 }
예제 #2
0
        /// <summary>
        /// Refreshes a short-lived access token using a longer-lived refresh token with
        /// a new access token that has the same scope as the refresh token.  The refresh
        /// token itself may also be refreshed.
        /// </summary>
        /// <param name="state">Provides access to a persistent object that tracks the state of an authorization.</param>
        /// <param name="authAgentClient">The auth user agent client.</param>
        /// <param name="skipIfUsefulLifeExceeds">If given, the access token will not be refreshed if its remaining lifetime
        /// exceeds this value.</param>
        /// <returns>A value indicating whether the access token was actually renewed; true if
        /// it was renewed, or false if it still had useful life remaining.</returns>
        public virtual bool RefreshAgentAuthorization(IAuthorizationState state, AuthAgentClient authAgentClient = null, TimeSpan?skipIfUsefulLifeExceeds = null)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            if (authAgentClient != null)
            {
                return(authAgentClient.RefreshAuthorization(state, skipIfUsefulLifeExceeds));
            }
            else
            {
                return(_authAgentClient.RefreshAuthorization(state, skipIfUsefulLifeExceeds));
            }
        }
예제 #3
0
 /// <summary>
 /// Request the user agent user authosisation with basic scope.
 /// </summary>
 /// <param name="authAgentClient">The auth user agent client.</param>
 /// <param name="state">The client state that should be returned with the authorization response.</param>
 /// <param name="returnTo">The URL that the authorization response should be sent to via a user-agent redirect.</param>
 public void RequestAgentUserAuthorizationBasicScope(AuthAgentClient authAgentClient = null, string state = null, Uri returnTo = null)
 {
     base.RequestAgentUserAuthorization(authAgentClient, new[] { WindowsLive.Scopes.Basic }, state, returnTo);
 }
예제 #4
0
        /// <summary>
        /// Scans the incoming request for an authorization response message.
        /// </summary>
        /// <param name="actualRedirectUrl">The actual URL of the incoming HTTP request.</param>
        /// <param name="authAgentClient">The auth user agent client.</param>
        /// <param name="authorizationState">The authorization.</param>
        /// <returns>The granted authorization, or null if the incoming HTTP request did not contain
        /// an authorization server response or authorization was rejected.</returns>
        public virtual IAuthorizationState ProcessAgentProcessUserAuthorization(Uri actualRedirectUrl, AuthAgentClient authAgentClient = null, IAuthorizationState authorizationState = null)
        {
            if (actualRedirectUrl == null)
            {
                throw new ArgumentNullException("actualRedirectUrl");
            }

            if (authAgentClient != null)
            {
                // Check to see if we're receiving a end user authorization response.
                return(authAgentClient.ProcessUserAuthorization(actualRedirectUrl, authorizationState));
            }
            else
            {
                // Check to see if we're receiving a end user authorization response.
                return(_authAgentClient.ProcessUserAuthorization(actualRedirectUrl, authorizationState));
            }
        }