如何 运行 这个 API 请求使用 Python

How to Run this API Request Using Python

我对 python 和 API 集成还很陌生。谁能告诉我如何使用 python 运行 这个 okta 文档?

curl -v -X GET
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: SSWS ${api_token}"
"https://${yourOktaDomain}/api/v1/apps"

您可以使用 urllib 来完成它。
示例:

from urllib.request import Request, urlopen

api_token = "..."
yourOktaDomain = "..."

headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Autorization": "SSWS " + api_token
}

request = Request("https://" + yourOktaDomain + "/api/v1/apps", headers=headers)
response = urlopen(request)
data = response.read()
import requests                                                         
import json


yourOktaDomain = 'something.okta.com'
api_token= ''

payload = ""
headers = {
    'Accept': "application/json",
    'Content-Type': "application/json",
    'Authorization': "SSWS "+api_token
    }
response1=requests.request("GET", 'https://'+{yourOktaDomain}+'/api/v1/apps', data=payload, headers=headers)
response1.json()