Connecting to Office 365 is the first step every app must take to start working with Office 365 services and data. This sample shows how to connect and then call one API through the Microsoft Graph API (previously called Office 365 unified API), and uses the Office Fabric UI to create an Office 365 experience.
![Office 365 Python Connect sample screenshot](./README assets/screenshot.PNG)
To use the Office 365 Python Connect sample, you need the following:
- Python 3.5.2
- Flask-OAuthlib
- Flask-Script 0.4
- A Microsoft account or an Office 365 for business account
Note: Microsoft has tested the Flask-OAuthlib library in basic scenarios and confirmed that it works with the v2.0 endpoint. Microsoft does not provide fixes for this library and has not done a review of it. Issues and feature requests should be directed to the library’s open-source project.
Register an app on the Microsoft App Registration Portal. This generates the app ID and password that you'll use to configure the app for authentication.
-
Sign into the Microsoft App Registration Portal using either your personal or work or school account.
-
Choose Add an app.
-
Enter a name for the app, and choose Create application.
The registration page displays, listing the properties of your app.
-
Copy the application ID. This is the unique identifier for your app.
-
Under Application Secrets, choose Generate New Password. Copy the app secret from the New password generated dialog.
You'll use the application ID and app secret to configure the app.
-
Under Platforms, choose Add platform > Web.
-
Make sure the Allow Implicit Flow check box is selected, and enter http://localhost:5000/login/authorized as the Redirect URI.
The Allow Implicit Flow option enables the OpenID Connect hybrid flow. During authentication, this enables the app to receive both sign-in info (the id_token) and artifacts (in this case, an authorization code) that the app uses to obtain an access token.
The redirect URI http://localhost:5000/login/authorized is the value that the OmniAuth middleware is configured to use once it has processed the authentication request.
-
Choose Save.
- Using your favorite IDE, open config.py in the connect directory.
- Replace ENTER_YOUR_CLIENT_ID with the client ID of your registered application.
- Replace ENTER_YOUR_SECRET with the key you generated for your app.
- Install the Requests: HTTP for Humans module from the command line by running
pip install requests
. - Start the development server by running
python manage.py runserver
. - Navigate to
http://localhost:5000/
in your web browser.
To learn more about the sample, see Python walkthrough on graph.microsoft.io.
If you'd like to contribute to this sample, see CONTRIBUTING.MD.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
We'd love to get your feedback about the Office 365 Python Connect sample. You can send your questions and suggestions to us in the Issues section of this repository.
Your feedback is important to us. Connect with us on Stack Overflow. Tag your questions with [MicrosoftGraph] and [office365].
Copyright (c) 2016 Microsoft. All rights reserved.