简体   繁体   English

在DropNetRT中使用Dropbox生成的访问令牌

[英]Using Dropbox Generated Access Token with DropNetRT

I'm using the DropNetRT library and I can't find a way to create a working DropNetClient using just the Generated Access Token from my app page in my Dropbox account. 我正在使用DropNetRT库,无法找到仅使用我的Dropbox帐户中的应用程序页面中的“生成的访问令牌”来创建有效的DropNetClient的方法。

If I use my User Secret and User Token it works: 如果我使用我的用户密码和用户令牌,则可以使用:

public static async Task UploadStuff()
{
    DropNetClient client = new DropNetClient("APIKey", "AppSecret");
    client.SetUserToken(new UserLogin() { Secret = "mySecret", Token = "myToken" });
    // Then upload the data with the client
}

But, instead of my UserToken and UserSecret, I just want to use my Generated Access Token. 但是,我只想使用我的生成的访问令牌,而不是我的UserToken和UserSecret。

It looks something like this, just to be sure: 看起来像这样,只是为了确保:

jfjfDkFkdfikAAAAAAAAAADkfkDJSJFJISjofdjFjjfoJOIDJSOjsFKPFKPEJKfjiksfd3_thD jfjfDkFkdfikAAAAAAAAAADkfkDJSJFJISjofdjFjjfoJOIDJSOjsFKPFKPEJKfjiksfd3_thD

Now, I tried using a UserLogin with just my Access Token as the Token and without a UserSecret, but the client threw an exception, so I guess that's not the right way to do that. 现在,我尝试使用仅以我的访问令牌作为令牌但没有UserSecret的UserLogin,但是客户端引发了异常,因此我认为这不是正确的方法。

How can I do that? 我怎样才能做到这一点? Is there a way to create a client with the access token with this library, or do I have to upload the file manually using an HttpClient? 是否可以通过该库使用访问令牌创建客户端,还是必须使用HttpClient手动上传文件? If so, I really have no idea on how to do that. 如果是这样,我真的不知道该怎么做。

Thanks! 谢谢!

Sergio 塞尔吉奥

Edit: this is what I tried (it's not working): 编辑:这是我尝试过的(不起作用):

public static async Task TestUploadGeneratedToken()
{
    // Create the client
    DropNetClient client = new DropNetClient("APIKey", "AppSecret");
    client.SetUserToken("MyGeneratedAccessToken", String.Empty);

    // Get a test file
    StorageFile tempFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("test.txt", CreationCollisionOption.OpenIfExists);
    await FileIO.WriteTextAsync(tempFile, "This is a simple test file");

    // Convert the file to a byte array
    IRandomAccessStream stream = await tempFile.OpenAsync(FileAccessMode.Read);
    stream.Seek(0);
    byte[] bytes = new byte[stream.Size];
    await stream.ReadAsync(bytes.AsBuffer(), (uint)stream.Size, InputStreamOptions.None);

    // Upload the file
    await client.Upload(CrashReportPath, "tokenTest.txt", bytes);
}

the Upload method throws a DropboxException. Upload方法将引发DropboxException。

That looks right. 看起来不错。 Try setting the secret to string.empty instead of null? 尝试将密码设置为string.empty而不是null?

I'm not sure if I have used a generated token before but can't see why it wouldn't work. 我不确定我以前是否使用过生成的令牌,但是看不到为什么它不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DropNetRT Dropbox JSON反序列化器似乎使用了错误的对象? - DropNetRT Dropbox JSON deserializer seems to be using the wrong sort of object? 使用Dropbox API在Windows窗体上获取Dropbox访问令牌 - Grabbing Dropbox access token on Windows Form using Dropbox API 使用Dropnet获取Dropbox访问令牌 - Getting Dropbox Access Token With Dropnet 使用DropBox身份验证网址动态生成身份验证令牌以访问Dropbox - Generate Auth token dynamically to Access Dropbox with DropBox Auth URL 使用DropNet从Dropbox存储用户令牌 - Store user token from Dropbox using DropNet 将DropNet与生成的访问令牌一起使用 - Use DropNet with generated access token Google OAuth使用JavaScript生成的OAuth access_token获取刷新令牌 - Google OAuth getting refresh token using javascript generated OAuth access_token 如何重定向到 dropbox 并使用访问令牌返回我的应用程序(如何使用 dropbox 登录) - How to redirect to dropbox and get back to my application with access token(how to login with dropbox) 将 ReactiveOAuth 与 Windows Phone 7 一起使用,以访问 Dropbox - Using ReactiveOAuth with Windows Phone 7, to access Dropbox 如何使用访问令牌请求 microsoft azure 资源? 简而言之,我们如何在 azure 中使用生成的 access_token? - How to request a microsoft azure resource using a access token? In short how can we use the generated access_token in azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM