Upwork OAuth2 Python Client

raw JSON →
3.2.0 verified Fri May 01 auth: no python

Python bindings for the Upwork API using OAuth2. Current version 3.2.0, supports Python >=3.8. This library replaces the old OAuth1-based client. Release cadence is irregular.

pip install python-upwork-oauth2
error ModuleNotFoundError: No module named 'upwork_api'
cause Using old import from the deprecated OAuth1 package.
fix
Install python-upwork-oauth2 and import from 'upwork' instead.
error AttributeError: module 'upwork' has no attribute 'UpworkClient'
cause Using wrong import path or outdated library version.
fix
Ensure you have v3.x installed: pip install python-upwork-oauth2>=3.0.0. Then from upwork import UpworkClient
error oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client)
cause Client credentials (client_id, client_secret) are incorrect or missing.
fix
Verify your client ID and secret in the Upwork developer portal. Use environment variables.
breaking v3.0.0 dropped OAuth1 support entirely. Import paths changed from upwork_api to upwork.
fix Replace 'from upwork_api import *' with 'from upwork import UpworkClient' and use OAuth2 grants.
breaking v3.2.0 removed calls to the legacy API. Endpoints under /api/* may no longer work.
fix Use only the current Upwork API endpoints (v2 or later). Review Upwork API changelog.
deprecated AuthorizationCodeGrant is deprecated in favor of ClientCredentialsGrant for machine-to-machine auth.
fix Switch to ClientCredentialsGrant unless you need user-specific tokens.
gotcha Token refresh must be handled manually. The library does not automatically refresh expired tokens.
fix Check token expiry and call grant.refresh_token() if needed.

Authenticate using Client Credentials Grant and create an UpworkClient.

import os
from upwork import UpworkClient
from upwork.oauth2 import ClientCredentialsGrant

client_id = os.environ.get('UPWORK_CLIENT_ID', '')
client_secret = os.environ.get('UPWORK_CLIENT_SECRET', '')

grant = ClientCredentialsGrant(
    client_id=client_id,
    client_secret=client_secret
)
token = grant.get_token()
client = UpworkClient(token=token)
# Now use client to call API endpoints
print(client.get_user_info())