gpt4 book ai didi

c# - 使用访问 token 登录 Dropbox

转载 作者:太空宇宙 更新时间:2023-11-03 13:07:56 25 4
gpt4 key购买 nike

我使用此代码(来自 Spring.NET Social Dropbox)通过 C# Winform 应用程序访问 Dropbox: https://github.com/spring-projects/spring-net-social-dropbox/blob/master/examples/Spring.ConsoleQuickStart/src/Spring.ConsoleQuickStart/Program.cs

DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.Full);
// Authorization without callback url
Console.Write("Getting request token...");
OAuthToken oauthToken = dropboxServiceProvider.OAuthOperations.FetchRequestTokenAsync(null , null).Result;
Console.WriteLine("Done");
OAuth1Parameters parameters = new OAuth1Parameters();
string authenticateUrl = dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, parameters);
Console.WriteLine("Redirect user for authorization");
Process.Start(authenticateUrl);
Console.Write("Press any key when authorization attempt has succeeded");
Console.ReadLine();
Console.Write("Getting access token...");
AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, null);
OAuthToken oauthAccessToken = dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
Console.WriteLine("Done");
IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

但我看到可以按照此处的说明直接获取访问 token : https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/

那么是否可以使用第二个链接中手动获取的访问 token 登录Dropbox?

我尝试将 token 直接传递给 dropboxServiceProvider.GetApi,但没有成功。

最佳答案

So is it possible to use the access token manually obtained as in the second link to sign in to Dropbox?

如果这是您的问题,答案是否定的。你不能。 Dropbox 在文档中说明了这一点。

Note that the generated access token only works for your own Dropbox account. Once you deploy your app to other users, you’ll need to use the standard OAuth authorization flow to acquire tokens for each user.

此外,还有一些关于您正在使用的库的信息。 spring-net-social-dropbox 最后一次更新是在 2012 年 11 月,而 Dropbox API 是 OAuth 1.0。现在使用的 OAuth2.0 版本保管箱是在 2013 年 7 月才宣布的。这实际上意味着您使用的是过时的库

更多最新 API 的链接:https://www.dropbox.com/developers/core/sdks/other

更新
DropNet 的文档: http://dropnet.github.io/dropnet.html

关于c# - 使用访问 token 登录 Dropbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30128728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com