Esempio n. 1
0
 /// <summary>
 /// Prepares a request for user authorization from an authorization server.
 /// </summary>
 /// <param name="authWebClient">The auth web client.</param>
 /// <param name="scopes">The scope of authorized access requested.</param>
 /// <param name="returnTo">The URL the authorization server should redirect the browser (typically on
 /// this site) to when the authorization is completed. If null, the current request's
 /// URL will be used.</param>
 public virtual void RequestWebUserAuthorization(AuthWebClient authWebClient = null, string[] scopes = null, Uri returnTo = null)
 {
     if (authWebClient != null)
     {
         authWebClient.RequestUserAuthorization(scopes, returnTo);
     }
     else
     {
         _authWebClient.RequestUserAuthorization(scopes, returnTo);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Processes the authorization response from an authorization server, if available.
 /// </summary>
 /// <param name="authWebClient">The auth web client.</param>
 /// <param name="request">The specific http request.</param>
 /// <returns>The authorization state that contains the details of the authorization.</returns>
 public virtual IAuthorizationState ProcessWebProcessUserAuthorization(AuthWebClient authWebClient = null, HttpRequestBase request = null)
 {
     if (authWebClient != null)
     {
         // Check to see if we're receiving a end user authorization response.
         return(authWebClient.ProcessUserAuthorization(request));
     }
     else
     {
         // Check to see if we're receiving a end user authorization response.
         return(_authWebClient.ProcessUserAuthorization(request));
     }
 }
Esempio n. 3
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="authWebClient">The auth web 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 RefreshWebAuthorization(IAuthorizationState state, AuthWebClient authWebClient = null, TimeSpan?skipIfUsefulLifeExceeds = null)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            if (authWebClient != null)
            {
                return(authWebClient.RefreshAuthorization(state, skipIfUsefulLifeExceeds));
            }
            else
            {
                return(_authWebClient.RefreshAuthorization(state, skipIfUsefulLifeExceeds));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Request the web user authosisation with basic scope.
 /// </summary>
 /// <param name="authWebClient">The auth web client.</param>
 /// <param name="returnTo">The URL the authorization server should redirect the browser (typically on
 /// this site) to when the authorization is completed. If null, the current request's
 /// URL will be used.</param>
 public void RequestWebUserAuthorizationBasicScope(AuthWebClient authWebClient = null, Uri returnTo = null)
 {
     base.RequestWebUserAuthorization(authWebClient, new[] { WindowsLive.Scopes.Basic }, returnTo);
 }