Forum Discussion
Http requests in Fabric Notebook
- Anonymous1 year ago
Hi pbi_taken,
Thank you for reaching out in Microsoft Community Forum.
Please follow below steps to Automating Strava API Data Access in Fabric Notebook
1.The code from the Strava OAuth flow is only needed once to retrieve the initial access_token and refresh_token. After that, you should use the refresh_token to keep getting new access_tokens without requiring the code again.
2.Replace grant_type = 'authorization_code' with grant_type = 'refresh_token' and call the token endpoint:
response = requests.post(
'https://www.strava.com/oauth/token',
data={
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'refresh_token',
'refresh_token': refresh_token
}
)3.If you're getting 401 errors, check the access_token permissions. You must have activity:read_all scope granted during the initial authorization. If the token lacks required scopes, reauthorize manually with:
4.Add debugging for response.status_code and print response.json() to catch and understand errors:
if response.status_code != 200:
print("Error during token fetch:", response.status_code, response.json())If the issue still persists,In this scenario we suggest you to raise a support ticket here. so, that they can assit you in addressing the issue you are facing. please follow below link on how to raise a support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
I really appreciate your help, but I still can't see a way around this..
according to strava documentation you need the code: Strava Developers.
trying what you suggested just results for me in a <Response [401]>..
Hmm really wish someone else has done this successfully in the past..
Hi pbi_taken,
Thank you for reaching out in Microsoft Community Forum.
Please follow below steps to Automating Strava API Data Access in Fabric Notebook
1.The code from the Strava OAuth flow is only needed once to retrieve the initial access_token and refresh_token. After that, you should use the refresh_token to keep getting new access_tokens without requiring the code again.
2.Replace grant_type = 'authorization_code' with grant_type = 'refresh_token' and call the token endpoint:
response = requests.post(
'https://www.strava.com/oauth/token',
data={
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'refresh_token',
'refresh_token': refresh_token
}
)
3.If you're getting 401 errors, check the access_token permissions. You must have activity:read_all scope granted during the initial authorization. If the token lacks required scopes, reauthorize manually with:
4.Add debugging for response.status_code and print response.json() to catch and understand errors:
if response.status_code != 200:
print("Error during token fetch:", response.status_code, response.json())
If the issue still persists,In this scenario we suggest you to raise a support ticket here. so, that they can assit you in addressing the issue you are facing. please follow below link on how to raise a support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn