Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Polishing doc and samples (verifier is not needed in ExchangeForAcces…

…sToken method for OAuth 1.0 providers)
  • Loading branch information...
commit 601361671fdbb9a3b45d79c11c0366bdb39b955e 1 parent fd280b2
@bbaia bbaia authored
View
5 doc/reference/src/api.xml
@@ -47,7 +47,7 @@ string authorizeUrl = oauthOperations.BuildAuthorizeUrl(requestToken, parameters
Response.Redirect(authorizeUrl);
// upon receiving the callback from the provider:
-OAuthToken accessToken = oauthOperations.ExchangeForAccessToken(new AuthorizedRequestToken(requestToken, oauthVerifier), null);
+OAuthToken accessToken = oauthOperations.ExchangeForAccessToken(new AuthorizedRequestToken(requestToken, null), null);
IDropbox dropboxApi = serviceProvider.GetApi(accessToken.Value, accessToken.Secret);]]></programlisting>
</para>
@@ -56,8 +56,7 @@ IDropbox dropboxApi = serviceProvider.GetApi(accessToken.Value, accessToken.Secr
<sbr/><interfacename>IDropbox</interfacename> is defined as follows:
</para>
- <programlisting language="csharp">
- <![CDATA[public interface IDropbox : IApiBinding
+ <programlisting language="csharp"><![CDATA[public interface IDropbox : IApiBinding
{
DropboxProfile GetUserProfile();
View
24 examples/Spring.ConsoleQuickStart/src/Spring.ConsoleQuickStart/Program.cs
@@ -25,9 +25,9 @@ static void Main(string[] args)
DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.Full);
#if NET_4_0
- /* OAuth 'dance' */
+ /* OAuth 1.0 'dance' */
- // Authentication using callback url
+ // Authorization without callback url
Console.Write("Getting request token...");
OAuthToken oauthToken = dropboxServiceProvider.OAuthOperations.FetchRequestTokenAsync(null , null).Result;
Console.WriteLine("Done");
@@ -35,13 +35,13 @@ static void Main(string[] args)
OAuth1Parameters parameters = new OAuth1Parameters();
//parameters.Add("locale", CultureInfo.CurrentUICulture.IetfLanguageTag); // for a localized version of the authorization website
string authenticateUrl = dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, parameters);
- Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
+ Console.WriteLine("Redirect user for authorization");
Process.Start(authenticateUrl);
- Console.WriteLine("Copy/Paste 'oauth_token' query string parameter from success url:");
- string verifier = Console.ReadLine();
+ Console.Write("Press any key when authorization attempt has succeeded");
+ Console.ReadLine();
Console.Write("Getting access token...");
- AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, verifier);
+ AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, null);
OAuthToken oauthAccessToken = dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
Console.WriteLine("Done");
@@ -106,9 +106,9 @@ static void Main(string[] args)
});
}
#else
- /* OAuth 'dance' */
+ /* OAuth 1.0 'dance' */
- // Authentication using callback url
+ // Authorization without callback url
Console.Write("Getting request token...");
OAuthToken oauthToken = dropboxServiceProvider.OAuthOperations.FetchRequestToken(null, null);
Console.WriteLine("Done");
@@ -116,13 +116,13 @@ static void Main(string[] args)
OAuth1Parameters parameters = new OAuth1Parameters();
//parameters.Add("locale", CultureInfo.CurrentUICulture.IetfLanguageTag); // for a localized version of the authorization website
string authenticateUrl = dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, parameters);
- Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
+ Console.WriteLine("Redirect user for authorization");
Process.Start(authenticateUrl);
- Console.WriteLine("Copy/Paste 'oauth_token' query string parameter from success url:");
- string verifier = Console.ReadLine();
+ Console.Write("Press any key when authorization attempt has succeeded");
+ Console.ReadLine();
Console.Write("Getting access token...");
- AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, verifier);
+ AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, null);
OAuthToken oauthAccessToken = dropboxServiceProvider.OAuthOperations.ExchangeForAccessToken(requestToken, null);
Console.WriteLine("Done");
View
4 examples/Spring.MvcQuickStart/Spring.MvcQuickStart/Controllers/DropboxController.cs
@@ -39,10 +39,10 @@ public ActionResult SignIn()
}
// GET: /Dropbox/Callback
- public ActionResult Callback(string oauth_token)
+ public ActionResult Callback()
{
OAuthToken requestToken = Session["RequestToken"] as OAuthToken;
- AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, oauth_token);
+ AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, null);
OAuthToken token = dropboxProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result;
Session["TokenValue"] = token.Value;
View
4 ...Spring.WindowsPhoneQuickStart/Spring.WindowsPhoneQuickStart/ViewModel/DropboxViewModel.cs
@@ -77,9 +77,9 @@ public void Authenticate()
});
}
- public void AuthenticateCallback(string verifier)
+ public void AuthenticateCallback()
{
- AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(this.requestOAuthToken, verifier);
+ AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(this.requestOAuthToken, null);
this.DropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null,
r =>
{
View
3  examples/Spring.WindowsPhoneQuickStart/Spring.WindowsPhoneQuickStart/Views/Dropbox.xaml.cs
@@ -55,8 +55,7 @@ private void WebBrowser_Navigating(object sender, NavigatingEventArgs e)
string url = e.Uri.ToString();
if (url.StartsWith(DropboxViewModel.CallbackUrl, StringComparison.OrdinalIgnoreCase))
{
- string verifier = url.Substring(url.LastIndexOf("oauth_token=") + 12);
- this.ViewModel.AuthenticateCallback(verifier);
+ this.ViewModel.AuthenticateCallback();
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.