문제

I am trying to make a connection to this API with requests. Specifically I was trying to access the "all applications" endpoint, yet I am having trouble making an initial connection.

>>> import requests
>>> 
>>> url = "https://manager.gimbal.com/api/applications"
>>> headers = {
... 'Authorization': 'Token <MyApiKeyIsHere>',
... 'content-type': 'application/json'
... }
>>> 
>>> 
>>> 
>>> r = requests.get(url, headers=headers)
>>> r
<Response [401]>

I am a bit confused as to why I am not getting an unauthorized connection to the API. If anyone can offer some pointers, that would be extremely helpful.

도움이 되었습니까?

해결책

The documentation seems to point out that the value is actually token=TOKEN, not just the token itself...

AUTHORIZATION: Token token=my_organization_server_api_key

Try replacing

'Authorization': 'Token <MyApiKeyIsHere>',

with this, and see if it responds properly

'Authorization': 'Token token=<MyApiKeyIsHere>',

다른 팁

Try to get result:

curl -X GET -H "Content-Type: application/json" -H "AUTHORIZATION: Token token=exxxx....xxxxxxxxxxxx6" https://manager.gimbal.com/api/applications

headers = { ... "Authorization: Token ", ... "content-type: application/json" ... }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top