/// <summary> /// Creates a new OAuth protected requests. /// </summary> /// <remarks> /// Since neither a request token nor an access token is supplied, /// the user will have to authorize this request. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <returns>An OAuth protected request for the protected resource</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings) { return(OAuthRequest.Create( resourceEndPoint, settings, new EmptyToken(settings.Consumer.Key, TokenType.Access), new EmptyToken(settings.Consumer.Key, TokenType.Request))); }
/// <summary> /// Creates a new OAuth protected request configured for an ASP.NET context. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <param name="endUserId">End user ID</param> /// <returns>An OAuth protected request for the protected resource, /// configured for an ASP.NET context</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, string endUserId) { OAuthRequest request = OAuthRequest.Create(resourceEndPoint, settings, callbackUri, endUserId); request.AuthorizationHandler = AspNetOAuthRequest.HandleAuthorization; request.VerificationHandler = AspNetOAuthRequest.HandleVerification; return(request); }
/// <summary> /// Creates a new OAuth protected request, initialised with previously /// retrieved request and access tokens, the specified callback /// </summary> /// <remarks> /// If the access token is valid, the user should not have to intervene /// to authorize the request and the protected resource should be /// fetched immediately. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback uri</param> /// <param name="requestToken">Request token</param> /// <param name="accessToken">Access token</param> /// <returns>An OAuth protected request for the protected resource, /// initialised with the request token and access token</returns> public static OAuthRequest Create( EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, IToken requestToken, IToken accessToken) { return(OAuthRequest.Create(resourceEndPoint, settings, callbackUri, requestToken, null, accessToken)); }
/// <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); }
/// <summary> /// Creates a new OAuth protected request, using the supplied end user ID /// in combination with the service to create a state key to load and /// store request state such as tokens. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <param name="endUserId">End user ID</param> /// <param name="verifier">Verifier</param> /// <returns>An OAuth protected request for the protected resource, /// initialised using the configured state store</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, string verifier, string endUserId) { var stateStore = settings.ComponentLocator.GetInstance <IRequestStateStore>(); var request = new OAuthRequest( resourceEndPoint, settings, verifier, stateStore, new RequestStateKey(settings, endUserId)); request.CallbackUrl = callbackUri; return(request); }
/// <summary> /// Creates a new OAuth protected request, initialised with previously /// retrieved request and access tokens, the specified callback /// </summary> /// <remarks> /// If the access token is valid, the user should not have to intervene /// to authorize the request and the protected resource should be /// fetched immediately. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback uri</param> /// <param name="requestToken">Request token</param> /// <param name="verifier">Verifier</param> /// <param name="accessToken">Access token</param> /// <returns>An OAuth protected request for the protected resource, /// initialised with the request token and access token</returns> public static OAuthRequest Create( EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, IToken requestToken, string verifier, IToken accessToken) { var state = new RequestState(new RequestStateKey(settings, null)) { RequestToken = requestToken, AccessToken = accessToken }; var request = new OAuthRequest(resourceEndPoint, settings, verifier, state); request.CallbackUrl = callbackUri; return(request); }
/// <summary> /// Creates a new OAuth protected request, using the supplied end user ID /// in combination with the service to create a state key to load and /// store request state such as tokens. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <param name="endUserId">End user ID</param> /// <returns>An OAuth protected request for the protected resource, /// initialised using the configured state store</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, string endUserId) { return(OAuthRequest.Create(resourceEndPoint, settings, callbackUri, null, endUserId)); }
/// <summary> /// Creates a new OAuth protected request, initialised with a previously /// retrieved request token. This token may or may not have been authorized. /// </summary> /// <remarks> /// If the request token supplied has not been authorized, the user will /// have to be directed to authorize it before the request can proceed. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="requestToken">Request token</param> /// <returns>An OAuth protected request for the protected resource</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, IToken requestToken) { return(OAuthRequest.Create(resourceEndPoint, settings, requestToken, null)); }
/// <summary> /// Creates a new OAuth protected request, initialised with previously /// retrieved request and access tokens, the specified callback /// </summary> /// <remarks> /// If the access token is valid, the user should not have to intervene /// to authorize the request and the protected resource should be /// fetched immediately. /// </remarks> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback uri</param> /// <param name="requestToken">Request token</param> /// <param name="verifier">Verifier</param> /// <param name="accessToken">Access token</param> /// <returns>An OAuth protected request for the protected resource, /// initialised with the request token and access token</returns> public static OAuthRequest Create( EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, IToken requestToken, string verifier, IToken accessToken) { var state = new RequestState(new RequestStateKey(settings, null)) { RequestToken = requestToken, AccessToken = accessToken }; var request = new OAuthRequest(resourceEndPoint, settings, verifier, state); request.CallbackUrl = callbackUri; return request; }
/// <summary> /// Creates a new OAuth protected request, using the supplied end user ID /// in combination with the service to create a state key to load and /// store request state such as tokens. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <param name="endUserId">End user ID</param> /// <param name="verifier">Verifier</param> /// <returns>An OAuth protected request for the protected resource, /// initialised using the configured state store</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, string verifier, string endUserId) { var stateStore = settings.ComponentLocator.GetInstance<IRequestStateStore>(); var request = new OAuthRequest( resourceEndPoint, settings, verifier, stateStore, new RequestStateKey(settings, endUserId)); request.CallbackUrl = callbackUri; return request; }