Skip to content

Latest commit

 

History

History
108 lines (66 loc) · 3.34 KB

File metadata and controls

108 lines (66 loc) · 3.34 KB

OAuth 2.0 Example: Python

This sample app will show you how to implement Adobe OAuth 2.0 in Python using the Flask framework.

After setting up the sample, you will have a Python app that:

  1. Serves templates/index.html on https://localhost:8000
  2. Lets a user log in with their Adobe ID
  3. Prompts the user to authorize the app with requested scopes
  4. Lets the user view their Adobe ID profile information
  5. Lets the user log out

Contents

  1. GitHub
  2. Technology Used
  3. Prerequisites
  4. Configuration
    1. Create an OpenSSL cert
    2. Install Python libraries
    3. Enter your Flask secret and Adobe API credentials
  5. Usage
  6. Other Resources

GitHub

You can find a companion repo for this developer guide on GitHub.

Be sure to follow all instructions in the readme.

Technology Used

  1. Python 2.6 or greater and the pip package manager
  2. OpenSSL CLI

Prerequisites

This guide will assume that you have read the Adobe OAuth 2.0 Guide for Web.

You must also have a registered app on the Adobe Developer Console with the following settings:

  1. Platform: web
  2. Default redirect URI: https://localhost:8000
  3. Redirect URI Pattern: https://localhost:8000

Configuration

The following steps will help you get this sample up and running.

Create an OpenSSL cert

Adobe OAuth 2.0 requires SSL, so you will need to create a self-signed cert using the OpenSSL CLI:

$ openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

Make sure that after running this command you have the cert.pem and key.pem files at the top level of the sample app.

Install Python libraries

This sample app uses the Flask, Requests, and Six libraries. You can install them using the pip package manager:

$ pip install flask
$ pip install requests
$ pip install six

Enter your Flask secret and Adobe API credentials

Enter the required credentials in config.py:

class Config(object):
    FLASK_SECRET = 'PLACEHOLDER_SECRET_KEY'
    ADOBE_API_KEY = 'YOUR_ADOBE_KEY'
    ADOBE_API_SECRET = 'YOUR_ADOBE_SECRET'

You can get your Adobe API Key and Secret from your registered app page on the Adobe Developer Console.

Usage

After completing the configuration steps, run adobe-oauth2.0.py:

$ python adobe-oauth2.0.py

To access the app, go to https://localhost:8000. Click through any cert warnings in the browser.

Other Resources