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
str or None
default:"None"
str or None
default:"None"
__init__
Initialize OAuth1 authentication.
Parameters
API Secret (Consumer Secret).
Callback URL for OAuth flow.
str or None
default:"None"
Access Token (if already obtained).
str or None
default:"None"
Access Token Secret (if already obtained).
Build OAuth1 authorization header for API requests.
Parameters
HTTP method (GET, POST, etc.).
Request URL (may include query parameters).
Request body (form-encoded string or empty).
Returns
str
get_access_token
Exchange verifier for access token.
Parameters
OAuth verifier from callback or PIN.
Returns
OAuth1AccessToken
get_authorization_url
Get the authorization URL for OAuth1 flow.
Parameters
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
Whether to use “Log in with X” flow.
Returns
str
class xdk.oauth1_auth.OAuth1AccessToken
OAuth1 access token response.
Parameters
__init__
Initialize OAuth1 access token.
Parameters
class xdk.oauth1_auth.OAuth1RequestToken
OAuth1 request token response.
Parameters
__init__
Initialize OAuth1 request token.
Parameters