无法获得imgur v3 api请求授权使用curl或其他bash实用程序

Dav*_*ave 4 authentication bash curl imgur

我正在尝试使用v3 imgur api从imgur.com获取一些公共数据,但每当我使用curl发出请求时,我都会收到401.

这就是我调用API的方法(使用示例python应用程序中的这个示例) -

curl -F "Authorization=Client-ID <my_client_id_provided_by_registering_my_app>" https://api.imgur.com/3/gallery/hot/viral/0.json
Run Code Online (Sandbox Code Playgroud)

我也试过了

curl -F "client_id=<my_client_id>" https://api.imgur.com/3/gallery/hot/viral/0.json
Run Code Online (Sandbox Code Playgroud)

所以我的问题是,imgur api期望使用auth标头的格式是什么,我如何利用curl或其他常见的bash实用程序来利用它?

nwk*_*nwk 5

交换机-F(或--form)用于发送HTTP表单.你应该使用的是-H(--header):

curl --header "Authorization: Client-ID $YOUR_ID" https://api.imgur.com/3/gallery/hot/viral/0.json
Run Code Online (Sandbox Code Playgroud)