Python API Wrapper for the public CodeOffer API
Project description
CodeOffer Python Package
This is a Python package that provides an API wrapper for the public CodeOffer API. The package simplifies authentication and management of in-app assets for developers who use the CodeOffer API in their applications.
Installation
To install the package, run the following command:
pip install codeoffer
Usage
Import the codeoffer class from the package:
Authentication & Sessions
Initialize a new session, but first you need to import the oauth class from codeoffer
from codeoffer import oauth
After that you can create a new session token:
token = session.create_session_token()
Now get the login link and ask the user to log in:
token.get_login_link()
Right after that call the token.wait_for_confirmation() method, this method will wait until the user completed the login-process.
To return the current logged in user you need to import the user class from codeoffer
from codeoffer import user
Then you can return the current user by using the get_user method and passing the token as a parameter:
user = user.User.get_user(token)
And now you can get the username, email, profile picture and access to the current logged in app (if the user purchased / downloaded the app with his account)
print(f"Hey {user.username}")
Assets
You can return all the apps your app contains.
First import the app class from codeoffer
from codeoffer import app
Then you need to initialize the app with a session token.
app = app.App.by_session_token(token)
After that you can return all the assets your app contains and return properties like the name, identifier and if the user has access to that asset.
assets = app.get_asset_directory()
for asset in assets:
print(f"{asset.name}: {asset.access}")
Complete Example
from codeoffer import oauth
from codeoffer import app
from codeoffer import user
session = oauth.Session("10aa641e562bdd82d2f8449d")
token = session.create_session_token()
token.get_login_link()
token.wait_for_confirmation()
user = user.User.get_user(token)
print(f"Hey {user.username}")
app = app.App.by_session_token(token)
assets = app.get_asset_directory()
for asset in assets:
print(f"{asset.name}: {asset.access}")
License
This package is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codeoffer-1.0.0.tar.gz.
File metadata
- Download URL: codeoffer-1.0.0.tar.gz
- Upload date:
- Size: 3.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a68db0c40291aa3f0e7a20922b1ff5b1555bd0a11eac5adc2ff3e1a65471c30
|
|
| MD5 |
6564c51bee939d5bd3ffa7f576ae540c
|
|
| BLAKE2b-256 |
0bfb7c890b81d3c08fe82caa6ba2b82120fb52e8c1770a567093dd58496c698b
|
File details
Details for the file codeoffer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: codeoffer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb1cd1c0842eaf19baaa9f9861c3a2b39c27baabce497041e8b0b2e8cb45775d
|
|
| MD5 |
8596e1c41cc35919b4fcb7f1644362a4
|
|
| BLAKE2b-256 |
c42d6629ae3614adf86fa3e5a47eec8eecda653b338d23a217ae804d70469e28
|