Coder Social home page Coder Social logo

pebsconsulting / active-directory-python-flask-graphapi-web-v2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/active-directory-python-flask-graphapi-web-v2

0.0 2.0 0.0 11 KB

Demonstrates how you can use a third party library to build a Python-Flask application that signs in users and gets an Access Token for the Microsoft Graph.

License: MIT License

HTML 21.09% Python 78.91%

active-directory-python-flask-graphapi-web-v2's Introduction

services platforms author
active-directory
python
navyasric

Sign in Azure AD + MSA Users using Python-Flask Open Source Libraries

Note

This sample is using a 3rd party library that has been tested for compatibility in basic scenarios with the v2.0 endpoint. Microsoft does not provide fixes for these libraries and has not done a review of these libraries. Issues and feature requests should be directed to the library's open-source project. Please see this document for more information.

This sample demonstrates how to use Azure AD with a 3rd party Python-Flask library (flask-oauthlib) to do oAuth 2.0 against the v2.0 endpoint. It then makes a call to the me endpoint of the Microsoft Graph to get information about the user.

Steps to Run

  1. Install Flask using pip if you don't already have it. If you do, make sure to update Flask.

    sudo pip install Flask
    
  2. Register your Azure AD v2.0 app.

    • Navigate to the App Registration Portal.
    • Go to the the My Apps page, click Add an App, and name your app.
    • Set a platform by clicking Add Platform, select Web, and add a Redirect URI of http://localhost:5000/login/authorized.
    • Click "Generate New Password' and record your Consumer Secret.
  3. Clone the code.

    git clone https://github.com/Azure-Samples/active-directory-python-flask-graphapi-web-v2
    
  4. In the top of v2flaskapp.py, add your Application/Client ID and Consumer Secret to the app config.

  5. Set your flask environment variable and run the sample in the terminal! Navigate to http://localhost:5000.

    $ export FLASK_APP=v2flaskapp.py && flask run
    

Questions and Issues

Please file any questions or problems with the sample as a github issue. You can also post on StackOverflow with the tag azure-active-directory. For oAuth2.0 library issues, please see note above.

This sample was tested with Python 2.7.10, Flask 0.11.1, and Flask-OAuthlib 0.9.3.

Acknowledgements

The flask & django libraries are built ontop of the core python oauthlib.

flask-oauthlib

oauthlib

django-oauth-toolkit

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.