Git Product home page Git Product logo

aspnet-connect-rest-sample's Introduction

Office 365 Connect ASP.NET MVC 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 use Microsoft Graph (previously called Office 365 unified API) to send an email. It uses Active Directory Authentication Library to make OAuth2 call.

![Office 365 ASP.NET MVC sample screenshot](./README assets/O365AspNetMVCSendMailPageScreenshot.png)

Prerequisites

To use the Office 365 ASP.NET MVC Connect sample, you need the following:

  • Visual Studio 2015 installed and working on your development computer.

    Note: This sample is written using Visual Studio 2015. If you're using Visual Studio 2013, make sure to change the compiler language version to 5 in the Web.config file: compilerOptions="/langversion:5

  • 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.

Register the app

  1. Sign in to the Azure portal.
  2. On the top bar, click on your account and under the Directory list, choose the Active Directory tenant where you wish to register your application.
  3. Click on More Services in the left hand nav, and choose Azure Active Directory.
  4. Click on App registrations and choose Add.
  5. Enter a friendly name for the application, for example 'MSGraphConnectAspNet' and select 'Web app/API' as the Application Type. For the Sign-on URL, enter http://localhost:55065. Click on Create to create the application.
  6. While still in the Azure portal, choose your application, click on Settings and choose Properties.
  7. Find the Application ID value and copy it to the clipboard.
  8. Configure Permissions for your application:
  9. In the Settings menu, choose the Required permissions section, click on Add, then Select an API, and select Microsoft Graph.
  10. Then, click on Select Permissions and select Sign in and read user profile and Send mail as a user. Click Select and then Done.
  11. In the Settings menu, choose the Keys section. Enter a description and select a duration for the key. Click Save.
  12. Important: Copy the key value. You won't be able to access this value again once you leave this pane. You will use this value as your app secret.

Configure and run the app

  1. Open UnifiedApiConnect.sln file.

  2. In Solution Explorer, open the Web.config file.

  3. Replace ENTER_YOUR_CLIENT_ID with the app ID of your registered Azure application.

  4. Replace ENTER_YOUR_SECRET with the key of your registered Azure application.

  5. Press F5 to build and debug. Run the solution and sign in to Office 365 with your organizational account.

    Note: Copy and paste the start page URL address http://localhost:55065/home/index, to a different browser if you get the following error during sign in:AADSTS70001: Application with identifier ad533dcf-ccad-469a-abed-acd1c8cc0d7d was not found in the directory.

Contributing

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 [email protected] with any additional questions or comments.

Questions and comments

We'd love to get your feedback about the Office 365 ASP.NET MVC Connect sample. You can send your questions and suggestions to us in the Issues section of this repository.

Questions about Office 365 development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [Office365] and [MicrosoftGraph].

Additional resources

Copyright

Copyright (c) 2015 Microsoft. All rights reserved.

aspnet-connect-rest-sample's People

Contributors

andrewjmay avatar davidchesnut avatar ricalo avatar tadaomachida avatar

Watchers

 avatar  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.