Dribbble api version 2

时间:2018-02-03 10:47:58

标签: javascript api

I've used the v1 of the Dribbble's API to show all my shots on my portfolio page. It requires the Client Access Token and nothing more. A few days ago I updated Client Access Token and got the error which says that v1 API is deprecated and I must use the v2. I read the documentaion and didn't find any approaches to use the API without OAuth 2.

Is it possible to use updated Dribbble's API without OAuth 2? According to the docs I can't show shots in my portfolio as I did before.

1 个答案:

答案 0 :(得分:5)

你需要使用OAuth,如果你注意到v1将在2018年3月被弃用。起初我在v2获得access token的文档时感到有些困惑,但是很少有时间尝试我能够弄清楚如何获得access token

首先,您需要Register Application。请注意您在Callback URL中添加的内容,因为它后来很重要。

例如,我的回调网址为http://grim.com

在终端上的我的Mac上引用OAuth,我运行了curl

curl GET https://dribbble.com/oauth/authorize?client_id=CLIENT_ID_FROM_APPLICATION

运行curl后,我复制了从响应中返回的链接并运行open URL,在浏览器中我提示登录。登录后我被问到是否要接受,然后我被重定向到Callback URL。在浏览器中从重定向复制代码的最后一部分,URL将如下所示:

http://grim.com?code=sadhjsahdjksahdjsahdjsahdkjsa

复制代码(?code=sadhjsahdjksahdjsahdjsahdkjsa)后,我打开Postman并将其从Post更改为Get

我通过了:

https://dribbble.com/oauth/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&code=sadhjsahdjksahdjsahdjsahdkjsa

我被退回了:

{
    "access_token":"1323213h23h2131j2h3jk12",
    "token_type":"bearer",
    "scope":"public",
    "created_at":13211421
}

我们可以在终端中使用令牌:

curl "https://api.dribbble.com/v2/user?access_token=1323213h23h2131j2h3jk12"

并且user的返回应该在终端中。可能有一个更好的解决方案,但希望这有帮助。