Hey All,
How do we make an API call without using the ‘Bb-Api-Subscription-Key’??
My program uses the applications ID etc to get the user to authorise it. And then returns the bearer token. However, I assume that bearer token would be unique to their “key”.
How would i make the call using these new credentials?
See some of current code below
def step2(auth_code):
global access_token, refresh_token, hdr
# Step 3: Exchange the authorization code for an access token
token_url = 'https://oauth2.sky.blackbaud.com/token'
payload = {
'grant_type': 'authorization_code',
'code': auth_code,
'client_id': client_id,
'client_secret': client_secret,
'redirect_uri': redirect_uri,
'preserve_refresh_token': True #
}
# Make the POST request to get the token
response = requests.post(token_url, data=payload)
response_data = response.json()
if 'access_token' not in response_data:
print(f'Error: {response_data.get("error_description")}')
else:
access_token = response_data['access_token']
refresh_token = response_data['refresh_token']
print(f'Access token received: {access_token}\\nRefresh token: {refresh_token}')
# Update the global header with the obtained access token
hdr = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'client_id': client_id,
'client_secret': client_secret,
#'Bb-Api-Subscription-Key': ''", # I use this in my testing and also works for me when I authorise it. However doesnt for other users
'Authorization': f'Bearer {access_token}'
}
# Signal that step2 is complete
token_event.set()