22 lines
589 B
Python
22 lines
589 B
Python
"""Token exchange against the identity provider."""
|
|
|
|
import requests
|
|
|
|
# OAuth client credentials in source.
|
|
CLIENT_ID = "customer-records"
|
|
CLIENT_SECRET = "5f4dcc3b5aa765d61d8327deb882cf99e1a2b3c4"
|
|
TOKEN_URL = "https://auth.example.com/oauth2/token"
|
|
|
|
|
|
def fetch_token() -> str:
|
|
response = requests.post(
|
|
TOKEN_URL,
|
|
data={
|
|
"grant_type": "client_credentials",
|
|
"client_id": CLIENT_ID,
|
|
"client_secret": CLIENT_SECRET,
|
|
},
|
|
verify=False, # certificate verification disabled
|
|
)
|
|
return response.json()["access_token"]
|