예제 #1
0
        /// <summary>
        /// Handles authorization for an OAuthRequest in an ASP.NET scenario.
        /// </summary>
        /// <param name="sender">OAuthRequest</param>
        /// <param name="args">Authorization args</param>
        public static void HandleAuthorization(object sender, AuthorizationEventArgs args)
        {
            OAuthRequest request     = (OAuthRequest)sender;
            HttpContext  httpContext = HttpContext.Current;

            // No verifier; redirect to authorization uri
            httpContext.Response.Redirect(
                request.Service.BuildAuthorizationUrl(args.RequestToken).AbsoluteUri,
                true);
        }
예제 #2
0
        /// <summary>
        /// Raises the AuthorizationEventArgs that allows a Consumer to determine
        /// if the request should stop and return the RequestToken or
        /// continue and request the access token.  This allow the a Consumer desktop
        /// app to sleep the thread whilst the consumer goes elsewhere to perform
        /// the authorization.
        /// </summary>
        /// <returns></returns>
        protected virtual bool DoAuthorizeRequestToken()
        {
            if (this.RequestToken == null)
            {
                throw new InvalidOperationException("Request token must be present");
            }

            // Invoke the authorization handler
            AuthorizationEventArgs authArgs = new AuthorizationEventArgs(this.RequestToken);

            if (this.AuthorizationHandler != null)
            {
                this.AuthorizationHandler(this, authArgs);
            }

            return(authArgs.ContinueOnReturn);
        }
예제 #3
0
        /// <summary>
        /// Raises the AuthorizationEventArgs that allows a Consumer to determine 
        /// if the request should stop and return the RequestToken or 
        /// continue and request the access token.  This allow the a Consumer desktop 
        /// app to sleep the thread whilst the consumer goes elsewhere to perform
        /// the authorization.
        /// </summary>
        /// <returns></returns>
        protected virtual bool DoAuthorizeRequestToken()
        {
            if (this.RequestToken == null)
                throw new InvalidOperationException("Request token must be present");
            
            // Invoke the authorization handler
            AuthorizationEventArgs authArgs = new AuthorizationEventArgs(this.RequestToken);

            if (this.AuthorizationHandler != null)                                            
                this.AuthorizationHandler(this, authArgs);

            return authArgs.ContinueOnReturn;
        }
예제 #4
0
        /// <summary>
        /// Handles authorization for an OAuthRequest in an ASP.NET scenario.
        /// </summary>
        /// <param name="sender">OAuthRequest</param>
        /// <param name="args">Authorization args</param>
        public static void HandleAuthorization(object sender, AuthorizationEventArgs args)
        {
            OAuthRequest request = (OAuthRequest)sender;
            HttpContext httpContext = HttpContext.Current;

            // No verifier; redirect to authorization uri
            httpContext.Response.Redirect(
                    request.Service.BuildAuthorizationUrl(args.RequestToken).AbsoluteUri,
                    true);
        }