Coder Social home page Coder Social logo

layer-identity-token-python's Introduction

Overview

The code in this folder provides examples for creating a Layer Identity Token for both the Flask and Django web frameworks.

Each example shows how to create an endpoint, identity_token, that requires the following parameters:

  • user_id: The user ID of the user you want to authenticate.
  • nonce: The nonce you receive from Layer. See docs for more info.

Response

Upon success, the endpoint will return a JSON object that contains a single key, identity_token. If the required input parameters were not provided, the endpoint will respond with "Invalid response."

Example successful response:

{
"identity_token": "eyJ0eXAiOiJKV1Mi..."
}

Python setup

For both examples, you need to first install the required Python libraries:

  • PyJWT - The officially supported JWT library for Python
  • pycrypto - Provides RSA signing capabilities for PyJWT

To install these modules, run the following command:

pip install -r requirements.txt

Note: the pip command may be pip3 if you are running Python 3.0+.

Configure your Layer app

To run either example, there are 3 constants that you should set in layer.py, all of which are available in the Keys section of the Layer dashboard for your app.

  • PROVIDER_ID - Provider ID found in the Layer Dashboard under "Keys"
  • KEY_ID - Public key generated and stored in the Layer Dashboard under "Keys"
  • RSA_KEY_PATH - Path to the file containing the private key associated with the public key

Detailed instructions

layer-identity-token-python's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.