Hello,
Is there anybody, who could provide me with some Python code to access the Workfront API using OAuth2 authorization code flow?
I am currently too dump to make some progress on this issue...
Thanks in advance.
Regards
Lars
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @lgaertner
from requests_oauthlib import OAuth2Session
authorization_base_url = "https://<your-domain>.my.workfront.com/attask/oauth/authorize"
token_url = "https://<your-domain>.my.workfront.com/attask/oauth/token"
client_id = "<your-client-id>" # Replace with your client ID
redirect_uri = "<your-redirect-URI>" # Replace with your redirect URI
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri)
authorization_url, state = oauth.authorization_url(authorization_base_url)
webbrowser.open(authorization_url)
authorization_response = input('Enter the full callback URL')
token = oauth.fetch_token(
token_url,
authorization_response=authorization_response,
client_secret="<your-client-secret>") # Replace with your client secret
This is to get the User Profile:
response = oauth.get('https://<your-domain>.my.workfront.com/attask/api/user/profile')
print(response.json())
Views
Replies
Total Likes
Hi @lgaertner
from requests_oauthlib import OAuth2Session
authorization_base_url = "https://<your-domain>.my.workfront.com/attask/oauth/authorize"
token_url = "https://<your-domain>.my.workfront.com/attask/oauth/token"
client_id = "<your-client-id>" # Replace with your client ID
redirect_uri = "<your-redirect-URI>" # Replace with your redirect URI
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri)
authorization_url, state = oauth.authorization_url(authorization_base_url)
webbrowser.open(authorization_url)
authorization_response = input('Enter the full callback URL')
token = oauth.fetch_token(
token_url,
authorization_response=authorization_response,
client_secret="<your-client-secret>") # Replace with your client secret
This is to get the User Profile:
response = oauth.get('https://<your-domain>.my.workfront.com/attask/api/user/profile')
print(response.json())
Views
Replies
Total Likes
Hello Jvenkat,
Thanks a lot. Unfortunately it is not working for me yet...
I constantly do get the error message Missing access token parameter.
What do you use as redirect_uri and how is your callback URL formatted?
Regards
Lars
Views
Replies
Total Likes
Correction:
I got it finally working!!!
Here is my final code:
import webbrowser
from requests_oauthlib import OAuth2Session
# Client-side Configuration
client_id = "<clientID>" # Replace with your client ID
client_secret = "<clientSecret>"
redirect_uri = "http://127.0.0.1:8088" # Replace with your redirect URI
# OAuth endpoints given in the Workfront API documentation
authorization_base_url = 'https://oauth.my.workfront.com/integrations/oauth2/authorize'
token_url = 'https://<your-domain>.my.workfront.com/integrations/oauth2/api/v1/token'
response_type = 'code'
# Create the OAuth2 Session
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri)
# Redirect user to Workfront for authorization
authorization_url, state = oauth.authorization_url(authorization_base_url)
webbrowser.open(authorization_url)
# User will get an authorization code. Copy it
authorization_response = input('Enter the full callback URL: ')
# Exchange the authorization code for a token
token = oauth.fetch_token(
token_url,
authorization_response=authorization_response,
client_secret = client_secret)
print(token)
Thanks a lot @Jvenkat
Views
Replies
Total Likes
Not working for me could you please help me with the redirect url and callback URI im not sure what to put im trying to integrate with sb01 environment.
Views
Replies
Total Likes
Views
Replies
Total Likes
Yes, i just added the technical user in to workfront instance and granted him access
Views
Replies
Total Likes
Hi @lgaertner ,
I just wanted to check—has the code been updated recently, or is it still working as expected? On my end, it’s not working, and I keep encountering an error, see the attached screenshot, error is That page doesn't exist, i am tired of this error now.
Additionally, could you please confirm if it’s possible to use a localhost URL for the redirect_uri, or does it strictly require an HTTPS URL?
I would really appreciate your help—I've been troubleshooting this for the past few days and would love your guidance to move forward.
Thanks so much in advance!
Views
Replies
Total Likes