public static ICloudStorageAccessToken ExchangeGoogleDocsRequestTokenIntoAccessToken(GoogleDocsConfiguration configuration, String consumerKey, String consumerSecret, GoogleDocsRequestToken requestToken, String oAuthVerifier) { var consumerContext = new OAuthConsumerContext(consumerKey, consumerSecret); var serviceContext = new OAuthServiceContext(configuration.OAuthGetRequestTokenUrl.ToString(), configuration.OAuthAuthorizeTokenUrl.ToString(), configuration.AuthorizationCallBack.ToString(), GetAccessTokenUrl(configuration, oAuthVerifier)); var service = new OAuthService(); var accessToken = service.GetAccessToken(serviceContext, consumerContext, requestToken.RealToken); if (accessToken == null) throw new UnauthorizedAccessException(); return new GoogleDocsToken(accessToken, consumerKey, consumerSecret); }
/// <summary> /// This method is able to exchange the request token into an access token which can be used in /// sharpbox. It is necessary that the user validated the request via authorization url otherwise /// this call wil results in an unauthorized exception! /// </summary> /// <param name="configuration"></param> /// <param name="ConsumerKey"></param> /// <param name="ConsumerSecret"></param> /// <param name="DropBoxRequestToken"></param> /// <returns></returns> public static ICloudStorageAccessToken ExchangeDropBoxRequestTokenIntoAccessToken(DropBoxConfiguration configuration, String ConsumerKey, String ConsumerSecret, DropBoxRequestToken DropBoxRequestToken) { // build the consumer context var consumerContext = new OAuthConsumerContext(ConsumerKey, ConsumerSecret); // build up the oauth session var serviceContext = new OAuthServiceContext(configuration.RequestTokenUrl.ToString(), configuration.AuthorizationTokenUrl.ToString(), configuration.AuthorizationCallBack.ToString(), configuration.AccessTokenUrl.ToString()); // build the access token var svc = new OAuthService(); var accessToken = svc.GetAccessToken(serviceContext, consumerContext, DropBoxRequestToken.RealToken); if (accessToken == null) throw new UnauthorizedAccessException(); // create the access token return new DropBoxToken(accessToken, new DropBoxBaseTokenInformation { ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }); }