OAuth2.0 client for the Coursera App Platform.
Project description
This project is a library consisting of a command-line interface and a client for interacting with Coursera’s OAuth2 authorizes APIs. It’s a rewritten courseraoauth2client with python3 support.
Installation
Create virtualenv using python3:
virtualenv -p $(which python3) <path_to_env>
Activate created virtualenv:
source <path_to_env>/bin/activate
To install this SDK, execute:
pip install coaclient
pip is a python package manager.
Setup
Before using Coursera’s OAuth2 APIs, be sure you know your client id, client secret, and scopes you want for your application. You may create an application at https://accounts.coursera.org/console. When creating the application, set the Redirect URI to be http://localhost:9876/callback.
Command Line Interface
The project includes a command-line tool. Run:
coaclient --help
for a complete list of features, flags, and documentation.
config
Configures the Coursera OAuth2 client library.
Examples:
coaclient config add --app APP_NAME
Adds configuration for a new application to coaclient. And also prepares new storage for application authorization tokens in coaclient.
coaclient config authorize --app APP_NAME
Configures the tool to go through the authorization secret flow for application APP.
The Coaclient tries to open the default system browser(If this step fails, the Coaclient suggests to open a link in the browser manually). The application configuration will be saved to the local file if the request is succeeded. You should check the data you’ve provided to the library during application configuration if you see any errors in the browser.
coaclient config check-auth --app APP_NAME
Checks whether the current instance can authorize against Coursera’s API server for application APP
coaclient config display-auth-cache --app APP_NAME
Shows authorization cache for app. The auth and refresh tokens are truncated for security purposes. If you want to display them, you can add --no-truncate option. Don’t pass your tokens to the third parties!
coaclient config delete --app APP_NAME
Delete the application from configuration file if the application exists.
version
Returns the current version of the library
Examples:
coaclient version
loglevel
You can suppress output or get more detailed information by choosing a log level. It can be done by specifying the optional --log-level(-l) parameter. Valid choices are INFO, DEBUG, WARNING, ERROR, CRITICAL. Default loglevel is INFO.
Usage
import requests from coaclient import oauth2 ... app_name = 'my_application_name' url = 'https://api.coursera.org/api/externalBasicProfiles.v1?q=me&fields=name' auth = oauth2.build(app_name=app_name).authorizer response = requests.get(url, auth=auth) print(response.json())
If my_application_name was successfully configured, you will be able to successfully make a request. Otherwise, an exception will be thrown telling you to set up your application for API access.
Bugs / Issues / Feature Requests
Please use the Github issue tracker to document any bugs or other issues you encounter while using this tool.
Tests
To run tests, run: nosetests, or tox.
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
File details
Details for the file coaclient-1.2.0.tar.gz
.
File metadata
- Download URL: coaclient-1.2.0.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82720ce866b7a46bf48baf42fc0fa1ea251bb41ce97c9ede6a98f115878d9a69 |
|
MD5 | 84b11953b4003b4ae4d24b98b19a39b5 |
|
BLAKE2b-256 | 23f9c37be8abf6f71870b9c025bf8990cf37c0c54932596c2e8c55bed870ae93 |
File details
Details for the file coaclient-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: coaclient-1.2.0-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae87e1103110d1f63bf530c840377713043f6625718a7fccdbf0ebec85842a86 |
|
MD5 | e418cb9acb647fb5c4da8af8c6433f65 |
|
BLAKE2b-256 | 334e0d0298931346ae4527e70aeef2888e0b9f980905626c9ec956b2cadccda4 |