Skip to main content

An OAuth2 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 -h

for a complete list of features, flags, and documentation.

config

Configures the Coursera OAuth2 client library.

Examples:

coaclient config authorize --app APP

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

Checks whether the current instance can authorize against Coursera’s API server for application APP

coaclient config display-auth-cache --app APP

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

Delete the application from configuration file if the application exists.

version

Returns the current version of the library

Examples:

coaclient config version

loglevel

You can suppress output or get more detailed information by choosing a log level. It can be done by specifying the optional –loglevel(-l) parameter. Valid choices are INFO, DEBUG, WARNING, ERROR, TRACE. Default loglevel is INFO.

Usage

import requests
from coaclient import oauth2
...
app = 'my_application_name'
url = 'https://api.coursera.org/api/externalBasicProfiles.v1?q=me&fields=name'
auth = oauth2.build_oauth2(app=app).build_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

This version

1.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for coaclient, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size coaclient-1.0.1-py3-none-any.whl (15.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size coaclient-1.0.1.tar.gz (13.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page