Skip to main content
This module provides OAuth1.0a authentication functionality for secure authorization flows. Includes request token generation, authorization URL generation, access token exchange, and OAuth1 signature generation.

class xdk.oauth1_auth.OAuth1

OAuth1 authentication handler for the X API.

Parameters

path.api_key
str
path.api_secret
str
path.callback
str
path.access_token
str or None
default:"None"
path.access_token_secret
str or None
default:"None"

__init__

Initialize OAuth1 authentication.

Parameters

path.api_key
str
API Key (Consumer Key).
path.api_secret
str
API Secret (Consumer Secret).
path.callback
str
Callback URL for OAuth flow.
path.access_token
str or None
default:"None"
Access Token (if already obtained).
path.access_token_secret
str or None
default:"None"
Access Token Secret (if already obtained).

build_request_header

Build OAuth1 authorization header for API requests.

Parameters

path.method
str
HTTP method (GET, POST, etc.).
path.url
str
Request URL (may include query parameters).
body.body
str
default:"''"
Request body (form-encoded string or empty).

Returns

str

get_access_token

Exchange verifier for access token.

Parameters

path.verifier
str
OAuth verifier from callback or PIN.

Returns

OAuth1AccessToken

get_authorization_url

Get the authorization URL for OAuth1 flow.

Parameters

path.login_with_x
bool
default:"False"
Whether to use “Log in with X” flow.

Returns

str

get_request_token

Get request token to start OAuth1 flow. :returns: Request token with oauth_token and oauth_token_secret. :rtype: OAuth1RequestToken

Returns

OAuth1RequestToken

start_oauth_flow

Convenience method to start the OAuth1 flow.

Parameters

path.login_with_x
bool
default:"False"
Whether to use “Log in with X” flow.

Returns

str

class xdk.oauth1_auth.OAuth1AccessToken

OAuth1 access token response.

Parameters

path.access_token
str
path.access_token_secret
str

__init__

Initialize OAuth1 access token.

Parameters

path.access_token
str
The access token.
path.access_token_secret
str
The access token secret.

class xdk.oauth1_auth.OAuth1RequestToken

OAuth1 request token response.

Parameters

path.oauth_token
str
path.oauth_token_secret
str

__init__

Initialize OAuth1 request token.

Parameters

path.oauth_token
str
The OAuth token.
path.oauth_token_secret
str
The OAuth token secret.