您需要使用OAuth流以访问自己的Dropbox帐户吗?

发布于 2025-01-28 02:54:02 字数 154 浏览 2 评论 0 原文

我正在根据自己的帐户编写Dropbox集成。当文件删除时,我会响应网络钩通知,并将文件导入我们的后端系统之一。

来让我登录。

这一切都是在后端服务器代码中完成的,没有真正的机会弹出UI 小时。

将API与您自己的帐户一起使用时,是否有任何身份快捷方式?

I'm writing a dropbox integration against my own account. When file get dropped I respond to a webhook notification and import the files into one of our backend systems.

It's all done in back end server code and there is no real opportunity to pop up a UI to get me to sign in.

I've developed it so far using the access token you can get from the app console but that expires after a few hours.

Are there any auth shortcuts when using the API with just your own account?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

御守 2025-02-04 02:54:03

我首先为自己弄清楚了一些快捷方式,

因为它是一个背景过程,它需要使用“离线”访问权限并使用刷新令牌来获取短暂的“访问令牌”。

由于没有UI,并且仅适用于我自己的帐户,因此我可以通过此url

app id ex e shere}}}}& token_access_type = offline =离线

从浏览器获得授权代码。 rel =“ nofollow noreferrer”> https://www.dropbox.com/oauth2/authorize?client_id = 访问令牌&刷新令牌:

In Postman:

Post to https://api.dropboxapi.com/oauth2/token
Authorisation Basic
UserName = {{AppKey}}
Password = {{AppSecret}}


Body :x-ww-form-urlencoded
code = <<Auth Code From Browser>>
grant_type = authorization_code

这会通过access_token产生结果,并且刷新_token

只有在我撤回访问权限的情况下才会到期,因此可以安全地添加到我的配置中,并用于请求访问令牌或连接到客户端。

在我的情况下,它的c#

using (var dbx = new DropboxClient(refreshToken,appKey,appSecret))
{
    var myAccount = await dbx.Users.GetCurrentAccountAsync();
    String.Format("{0} - {1}", 
        myAccount.Name.DisplayName, 
        myAccount.Email)
       .Dump("Account Details");
}


I've figured out some shortcuts for myself

First off all as its a background process it needs to be running with "offline" access and using refresh tokens to acquire short lived access tokens.

As there is no UI and its only for my own account I can get an authorisation code via the browser from this URL

https://www.dropbox.com/oauth2/authorize?client_id={{Your APP ID Here}}&token_access_type=offline&response_type=code

then use POSTMAN to get an access Token & Refresh Token:

In Postman:

Post to https://api.dropboxapi.com/oauth2/token
Authorisation Basic
UserName = {{AppKey}}
Password = {{AppSecret}}


Body :x-ww-form-urlencoded
code = <<Auth Code From Browser>>
grant_type = authorization_code

This produces a result with an access_token and a refresh_token

The refresh token will only expire if I withdraw access so that will be safe to add into my config and use to request access tokens or connect to the client.

In my case its c#

using (var dbx = new DropboxClient(refreshToken,appKey,appSecret))
{
    var myAccount = await dbx.Users.GetCurrentAccountAsync();
    String.Format("{0} - {1}", 
        myAccount.Name.DisplayName, 
        myAccount.Email)
       .Dump("Account Details");
}


~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文