[英]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.