日历 API returns 一个 401
Calendly API returns a 401
我想在 Calendly 中使用我的用户请求进行 API 调用,例如 Documentation,但我做不到。我不知道我的代码中是否需要其他东西,谢谢。
import requests, json
api_key = 'aaaaaaaaa'
header = {
'Authorization' : api_key
}
response = requests.get('https://api.calendly.com/users/me/', headers= header)
print(response)
print(response.json())
我收到 401 响应:
<Response [401]> {'title': 'Unauthenticated', 'message': 'The access token is invalid'}
我怀疑您正在尝试将 API 密钥用于 API v2。 API 密钥仅适用于 Calendly 的遗留 API v1。 API v2支持以下两种授权方案:
- OAuth 授权代码流程,或
- 个人访问令牌。
有关详细信息,请参阅 developer.calendly.com/getting-started。
如果您在 API v2 中使用个人令牌,则需要在您的令牌前添加 Bearer
。
示例:
header = {
'Authorization': f'Bearer {api_key}'
}
来源:
https://calendly.stoplight.io/docs/api-docs/YXBpOjM5NQ-calendly-api
我想在 Calendly 中使用我的用户请求进行 API 调用,例如 Documentation,但我做不到。我不知道我的代码中是否需要其他东西,谢谢。
import requests, json
api_key = 'aaaaaaaaa'
header = {
'Authorization' : api_key
}
response = requests.get('https://api.calendly.com/users/me/', headers= header)
print(response)
print(response.json())
我收到 401 响应:
<Response [401]> {'title': 'Unauthenticated', 'message': 'The access token is invalid'}
我怀疑您正在尝试将 API 密钥用于 API v2。 API 密钥仅适用于 Calendly 的遗留 API v1。 API v2支持以下两种授权方案:
- OAuth 授权代码流程,或
- 个人访问令牌。
有关详细信息,请参阅 developer.calendly.com/getting-started。
如果您在 API v2 中使用个人令牌,则需要在您的令牌前添加 Bearer
。
示例:
header = {
'Authorization': f'Bearer {api_key}'
}
来源: https://calendly.stoplight.io/docs/api-docs/YXBpOjM5NQ-calendly-api