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
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
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())
조회 수
답글
좋아요 수
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())
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
조회 수
답글
좋아요 수
Yes, i just added the technical user in to workfront instance and granted him access
조회 수
답글
좋아요 수
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!
조회 수
답글
좋아요 수
Hi @VINAYPA2,
did manage to make the code work?
if yes, can u pls share it
Best,
Harihara
조회 수
답글
좋아요 수