HTTP 基本身份验证 - 无法连接
HTTP Basic Auth - Can't connect
我无法从 Wakatime API 中获取任何内容,我不知道出了什么问题。
文档指出:
Authentication to the API can be done using HTTP Basic Auth or by adding your api key as a query parameter in your request url like ?api_key=XXXX
. Using HTTP Basic Auth, your username is your API key base64 encoded. Your password is not needed to authenticate.
For example, when using HTTP Basic Auth with an API key of 12345 you should add this header to your request:
Authorization: Basic MTIzNDU=
我正在使用 HTTParty 来处理请求:
HTTParty.get('https://wakatime.com/api/v1/users/@theminijohn?api_key=XXX')
但是这个returns:
{
"error": "Not found"
}
我做错了什么?
- --> Wakatime API
- --> Api 键:XXX
- --> 用户名:theminijohn - https://wakatime.com/@theminijohn
您需要在 API 端点提供 用户 ID,而不是 用户名。
规格:
GET users/:user
表示:
GET users/:user.id
这个有效:
https://wakatime.com/api/v1/users/f0fbed96-0c45-4d01-89e4-6a595a23299b?api_key=XXXX
我的用户 ID 来自:
我无法从 Wakatime API 中获取任何内容,我不知道出了什么问题。
文档指出:
Authentication to the API can be done using HTTP Basic Auth or by adding your api key as a query parameter in your request url like
?api_key=XXXX
. Using HTTP Basic Auth, your username is your API key base64 encoded. Your password is not needed to authenticate.For example, when using HTTP Basic Auth with an API key of 12345 you should add this header to your request:
Authorization: Basic MTIzNDU=
我正在使用 HTTParty 来处理请求:
HTTParty.get('https://wakatime.com/api/v1/users/@theminijohn?api_key=XXX')
但是这个returns:
{
"error": "Not found"
}
我做错了什么?
- --> Wakatime API
- --> Api 键:XXX
- --> 用户名:theminijohn - https://wakatime.com/@theminijohn
您需要在 API 端点提供 用户 ID,而不是 用户名。
规格:
GET users/:user
表示:
GET users/:user.id
这个有效:
https://wakatime.com/api/v1/users/f0fbed96-0c45-4d01-89e4-6a595a23299b?api_key=XXXX
我的用户 ID 来自: