0
我知道SO上有幾個問題似乎回答了這個問題,但他們都沒有爲我完成這項工作。使用Python將令牌傳遞給REST Api
因此,這裏是我的代碼...
import requests
bearer_token = 'eyJhbGciOiJIUzI1NiIsImtpZCI6IlRFU1QifQ.eyJjbGllbnRpZCI6ImFhZDkyNjc5MmJiMjQ4YjRhZDcyYzk4ZDk0YTZhNTlhIiwidXNlcmlkIjoibmVpbC5oYXJsYW5kQG56cG9zdC5jby5ueiIsInVzZXJuYW1lIjoibmVpbC5oYXJsYW5kQG56cG9zdC5jby5ueiIsImV4cCI6MTQ4MTA2ODM0MSwic2NvcGUiOltdLCJjbGllbnRfaWQiOiJhYWQ5MjY3OTJiYjI0OGI0YWQ3MmM5OGQ5NGE2YTU5YSJ9.BaQk5kCmIWSd2PB2QtT0nbyG5a8FWxSudcbTsS4RvLA'
url = 'https://myapi/apiname/apiversion/endpoint/flow?param1=253¶m2=20'
def callMyApi():
print ("Calling API ...")
response = requests.get(url,headers={'Authorization': bearer_token})
print (response.text)
callMyApi()
這裏是respobse我得到...
Calling API ...
{ "error": "missing_access_token", "description": "The access token is missing." }
現在,我已經嘗試了許多品種,如...
response = requests.get(url,headers = {'Authorization':'token'+ bearer_token})
response = requests.get(url,head ERS = {「授權」:「基本」 + bearer_token})
我甚至試過base64編碼,以防萬一有與複雜bearer_token發生一些有趣的事情 - 即使它只是一個字符串
並沒有什麼作品。
任何幫助,將不勝感激
也許標記必須傳遞內部獲取請求作爲參數? 也就是說api.service?標記= {{令牌}} – Disciples