Skip to content

This sample shows how to connect your Python web app to Office 365 using Microsoft Graph to send an email.

License

Notifications You must be signed in to change notification settings

kcchien/O365-Python-Microsoft-Graph-Connect

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Office 365 Python Connect sample using Microsoft Graph

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.

Note: Try out the Get started with Office 365 APIs page which simplifies registration so you can get this sample running faster.

![Office 365 Python Connect sample screenshot](./README assets/screenshot.PNG)

Prerequisites

To use the Office 365 Python Connect sample, you need the following:

  • Python 3.4.3

  • Django 1.8

  • An Office 365 account. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building Office 365 apps.

    Note: If you already have a subscription, the previous link sends you to a page with the message Sorry, you can’t add that to your current account. In that case use an account from your current Office 365 subscription.

  • A Microsoft Azure tenant to register your application. Azure Active Directory (AD) provides identity services that applications use for authentication and authorization. A trial subscription can be acquired here: Microsoft Azure.

    Important: You also need to make sure your Azure subscription is bound to your Office 365 tenant. To do this, see the Active Directory team's blog post, Creating and Managing Multiple Windows Azure Active Directories. The section Adding a new directory will explain how to do this. You can also see Set up your Office 365 development environment and the section Associate your Office 365 account with Azure AD to create and manage apps for more information.

  • A client ID, client secret, and redirect URI values of an application registered in Azure. This sample application must be granted the Send mail as signed-in user and Send mail as signed-in user permissions for the Microsoft Graph application. Add a web server application in Azure and grant the proper permissions to it.

    Note: During the app registration process, make sure to specify http://127.0.0.1:8000/connect/get_token/ as the Sign-on URL.

Configure and run the app

  1. Using your favorite IDE, open config.py in the connect directory.
  2. Replace ENTER_YOUR_CLIENT_ID with the client ID of your registered Azure application.
  3. Replace ENTER_YOUR_SECRET with a key generated on the Configure page of your app in the Microsoft Azure Management Portal.
  4. Install the Requests: HTTP for Humans module from the command line by running pip install requests.
  5. Set up the server by running python manage.py migrate. This command will synchronize the database state with the current set of migrations.
  6. Start the development server by running python manage.py runserver.
  7. Navigate to http://127.0.0.1:8000/ in your web browser.

To learn more about the sample, see Python walkthrough on graph.microsoft.io.

Questions and 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].

Additional resources

Copyright

Copyright (c) 2015 Microsoft. All rights reserved.

About

This sample shows how to connect your Python web app to Office 365 using Microsoft Graph to send an email.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 83.4%
  • HTML 16.6%