Skip to content

Simplify OAuth2 authorizations between an external service and Open edX

License

Notifications You must be signed in to change notification settings

colin-byrne-1/ibl-edx-oauth-api-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IBL edX OAuth API Client

Helper Django application that simplifies the OAuth2 authorization process between an external service and Open edX.

It exchanges Open edX OAuth2 client_id and client_secret credentials for an access_token that is saved to its database and made available to other processes.

Usage

Use the following wherever you need to make a call to Open edX that is protected by an authorization layer.

from ibl_edx_oauth_api_client import oauth_utils

# URL of your Open edX platform's protected API endpoint
url = 'https://your-open-edx-platform/some-protected-api-endpoint'

token = oauth_utils.get_current_access_token()
headers = {'Authorization': 'JWT {}'.format(token)}

response = requests.get(url=url, headers=headers)

Setup

Installation

Clone and install the application.

$ pip install -v git+https://github.com/ibleducation/ibl-edx-oauth-api-client.git

Django

Add ibl_edx_oauth_api_client to INSTALLED_APPS

INSTALLED_APPS = [
    ...,
    'ibl_edx_oauth_api_client'
]

Add your Open edX Platform's Credentials

Define the following in your settings:

A dictionary named EDX_OAUTH:

EDX_OAUTH = {
    'client_id': 'your_client_id',
    'client_secret': 'your_client_secret'
}

A dictionary named EDX_HOST:

EDX_HOST = {
    'host_name': 'your-open-edx-platform.com',
    'protocol': 'https',
    'access_token_api': '/oauth2/access_token',
}

Migrations

Run migrations to add the OauthCredentials table to the database.

$ python manage.py makemigrations
$ python manage.py migrate

About

Simplify OAuth2 authorizations between an external service and Open edX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%