Skip to content

Commit 8ecc5de

Browse files
chore: update SDK to v0.3.0
1 parent f3e98d9 commit 8ecc5de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7791
-7785
lines changed

conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
project = "X API SDK"
2222
copyright = "2024, X Developer Platform"
2323
author = "X Developer Platform"
24-
release = "0.2.7-beta"
25-
version = "0.2.7-beta"
24+
release = "0.3.0"
25+
version = "0.3.0"
2626

2727
# -- General configuration ----------------------------------------------------
2828

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build-backend = "hatchling.build"
1414

1515
[project]
1616
name = "xdk"
17-
version = "0.2.7-beta"
17+
version = "0.3.0"
1818
description = "Python SDK for the X API"
1919
authors = [
2020
{name = "X Developer Platform", email = "devs@x.com"},

scripts/process-for-mintlify.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
MINTLIFY_CONFIG = {
2525
"outputDir": "mintlify-docs",
2626
"baseUrl": "https://docs.x.com",
27-
"title": "X API SDK v0.2.7-beta",
27+
"title": "X API SDK v0.3.0",
2828
"description": "Python SDK for the X API with comprehensive pagination, authentication, and streaming support.",
29-
"version": "0.2.7-beta",
29+
"version": "0.3.0",
3030
"githubUrl": "https://github.com/xdevplatform/xdk",
3131
}
3232

@@ -1270,36 +1270,40 @@ def process_docs():
12701270
3. Initiate the flow, direct user to auth URL and handle callback.
12711271
**Example** (using a web server for callback):
12721272
```python
1273-
from xdk.auth import OAuth2PKCE
1273+
from xdk.oauth2_auth import OAuth2PKCEAuth
12741274
from urllib.parse import urlparse
12751275
import webbrowser
12761276
# Step 1: Create PKCE instance
1277-
auth = OAuth2PKCE(
1278-
client_id="your_client_id",
1279-
redirect_uri="http://localhost:8080/callback",
1280-
scopes=["tweet.read", "users.read", "offline.access"] # Adjust scopes as needed
1277+
auth = OAuth2PKCEAuth(
1278+
client_id="YOUR_CLIENT_ID",
1279+
redirect_uri="YOUR_CALLBACK_URL",
1280+
scope="tweet.read users.read offline.access"
12811281
)
12821282
# Step 2: Get authorization URL
1283-
auth_url = auth.get_authorization_url()
1283+
auth_url, state = auth.get_authorization_url()
12841284
print(f"Visit this URL to authorize: {auth_url}")
12851285
webbrowser.open(auth_url)
12861286
# Step 3: Handle callback (in a real app, use a web framework like Flask)
12871287
# Assume callback_url = "http://localhost:8080/callback?code=AUTH_CODE_HERE"
12881288
callback_url = input("Paste the full callback URL here: ")
1289-
parsed = urlparse(callback_url)
1290-
code = parsed.query.split("=")[1]
12911289
# Step 4: Exchange code for tokens
1292-
tokens = auth.fetch_token(authorization_code=code)
1290+
tokens = auth.fetch_token(authorization_response=callback_url)
12931291
access_token = tokens["access_token"]
12941292
refresh_token = tokens["refresh_token"] # Store for renewal
12951293
# Step 5: Create client
1296-
client = Client(oauth2_access_token=access_token)
1294+
# Option 1: Use bearer_token (OAuth2 access tokens work as bearer tokens)
1295+
client = Client(bearer_token=access_token)
1296+
# Option 2: Pass the full token dict for automatic refresh support
1297+
# client = Client(token=tokens)
12971298
```
12981299
**Token Refresh** (automatic in SDK for long-lived sessions):
12991300
```python
13001301
# If access token expires, refresh using stored refresh_token
1301-
tokens = auth.refresh_token(refresh_token=refresh_token)
1302-
client = Client(oauth2_access_token=tokens["access_token"])
1302+
# The refresh_token method uses the stored token from the OAuth2PKCEAuth instance
1303+
tokens = auth.refresh_token()
1304+
# Use the refreshed token
1305+
client = Client(bearer_token=tokens["access_token"])
1306+
# Or pass the full token dict: client = Client(token=tokens)
13031307
```
13041308
### 3. OAuth 1.0a User Context
13051309
For legacy endpoints that require OAuth 1.0 support.

tests/account_activity/test_contracts.py

Lines changed: 121 additions & 121 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)