public OAuthManager(IHttpListenerManager listenerManager, DesktopConsumer consumer, MessageReceivingEndpoint serviceEndPoint) { _listenerManager = listenerManager; _consumer = consumer; _serviceEndPoint = serviceEndPoint; }
public static Uri PrepareRequestAuthorization(DesktopConsumer consumer, out string requestToken) { if (consumer == null) { throw new ArgumentNullException("consumer"); } Uri authorizationUrl = consumer.RequestUserAuthorization(null, null, out requestToken); return authorizationUrl; }
/// <summary> /// 请求授权 /// </summary> public static Uri RequestAuthorization(DesktopConsumer consumer, out string requestToken) { if (consumer == null) { throw new ArgumentNullException("YDDesktopConsumer"); } var uri = consumer.RequestUserAuthorization(null, null, out requestToken); return uri; }
public OAuthManager(IHttpListenerManager listenerManager, DesktopConsumer consumer, MessageReceivingEndpoint serviceEndPoint) { this._listenerManager = listenerManager; this._consumer = consumer; this._serviceEndPoint = serviceEndPoint; // Trying to fix https://github.com/flickr-downloadr/flickr-downloadr-gtk/issues/15 // From the comment in this SO answer: // http://stackoverflow.com/questions/1186682/expectation-failed-when-trying-to-update-twitter-status/2025073#2025073 ServicePointManager.FindServicePoint(this._serviceEndPoint.Location).Expect100Continue = false; }
internal Authorize(DesktopConsumer consumer, FetchUri fetchUriCallback) { this.InitializeComponent(); this.consumer = consumer; Cursor original = this.Cursor; this.Cursor = Cursors.Wait; ThreadPool.QueueUserWorkItem(delegate(object state) { Uri browserAuthorizationLocation = fetchUriCallback(this.consumer, out this.requestToken); System.Diagnostics.Process.Start(browserAuthorizationLocation.AbsoluteUri); this.Dispatcher.BeginInvoke(new Action(() => { this.Cursor = original; finishButton.IsEnabled = true; })); }); }
public static AuthorizedTokenResponse CompleteAuthorization(DesktopConsumer consumer, string requestToken, string userCode) { // Because Yammer has a proprietary callback_token parameter, and it's passed // with the message that specifically bans extra arguments being passed, we have // to cheat by adding the data to the URL itself here. var customServiceDescription = new ServiceProviderDescription { RequestTokenEndpoint = ServiceDescription.RequestTokenEndpoint, UserAuthorizationEndpoint = ServiceDescription.UserAuthorizationEndpoint, AccessTokenEndpoint = new MessageReceivingEndpoint(ServiceDescription.AccessTokenEndpoint.Location.AbsoluteUri + "?oauth_verifier=" + Uri.EscapeDataString(userCode), HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest), TamperProtectionElements = ServiceDescription.TamperProtectionElements, ProtocolVersion = ProtocolVersion.V10, }; // To use a custom service description we also must create a new WebConsumer. var customConsumer = new DesktopConsumer(customServiceDescription, consumer.TokenManager); var response = customConsumer.ProcessUserAuthorization(requestToken, userCode); return response; }
public TwitterConsumer(string consumerKey, string consumerSecret) { ConsumerKey = consumerKey; ConsumerSecret = consumerSecret; var providerDescription = new ServiceProviderDescription { RequestTokenEndpoint = new MessageReceivingEndpoint("https://api.twitter.com/oauth/request_token", HttpDeliveryMethods.PostRequest), UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://api.twitter.com/oauth/authorize", HttpDeliveryMethods.GetRequest), AccessTokenEndpoint = new MessageReceivingEndpoint("https://api.twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest), TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() } }; Consumer = new DesktopConsumer( providerDescription, new TokenManager(ConsumerKey, ConsumerSecret)); return; }
/// <summary> /// Requests authorization from Google to access data from a set of Google applications. /// </summary> /// <param name="consumer">The Google consumer previously constructed using <see cref="CreateWebConsumer"/> or <see cref="CreateDesktopConsumer"/>.</param> /// <param name="requestedAccessScope">The requested access scope.</param> /// <param name="requestToken">The unauthorized request token assigned by Google.</param> /// <returns>The request token</returns> public static Uri RequestAuthorization(DesktopConsumer consumer, Applications requestedAccessScope, out string requestToken) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var extraParameters = new Dictionary<string, string> { { "scope", GetScopeUri(requestedAccessScope) }, }; return consumer.RequestUserAuthorization(extraParameters, null, out requestToken); }
private void SetAccessToken(DesktopConsumer consumer) { ((InMemoryTokenManager)consumer.TokenManager).AddAccessTokenAndSecret( Settings.Default.AccessToken.DecryptBase64EncodedString(), Settings.Default.SharedSecret.DecryptBase64EncodedString()); }
private static DesktopConsumer CreateConsumer(CrunchAuthorisationParameters crunchAuthorisationParameters) { var tokenManager = new InMemoryTokenManager(crunchAuthorisationParameters.ConsumerKey, crunchAuthorisationParameters.SharedSecret); var serviceProviderDescription = CreateServiceProviderDescription(crunchAuthorisationParameters); var consumer = new DesktopConsumer(serviceProviderDescription, tokenManager); return consumer; }
protected override void InitializeImpl() { this._consumer = new DesktopConsumer(new ServiceProviderDescription { AccessTokenEndpoint = new MessageReceivingEndpoint( "https://twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest ), ProtocolVersion = ProtocolVersion.V10a, RequestTokenEndpoint = new MessageReceivingEndpoint( "https://twitter.com/oauth/request_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest ), UserAuthorizationEndpoint = new MessageReceivingEndpoint( "https://twitter.com/oauth/authorize", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest ), TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() }, }, new TokenManager(this.Host.Directories.RuntimeDirectory.File(this + "_token.dat"))); }
public MainWindow() { InitializeComponent(); this.google = GoogleConsumer.CreateDesktopConsumer(this.tokenManager, string.Empty); }