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
Views
Likes
Replies