ナビゲーションをスキップする

Sign in Azure AD + MSA Users using 3rd Party JavaScript OAuth Library (Hello.js)

最終更新: 2018/04/10
GitHub で編集
Getting Started Library Docs Support

[!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 Javascript library (hello.js) to do an OAuth 2.0 flow against the v2.0 endpoint. Hello.js also provides code for calling web APIs which the sample has preconfigured to support the Microsoft Graph /me endpoint, and provides a structure for making MS Graph calls.

Register the application

Register your app with Azure AD v2.0 as follows: 1. Go to the Microsoft Application Registration Portal to register an application 2. Enter a name for your application 3. Make sure the option for Guided Setup is unchecked 4. Click Add Platform, then select Web 5. Add a Redirect URI of http://localhost:8000/redirect.html 6. Click Save

Build and Run the sample

  1. Install hello.js.
  npm install -g bower
  bower install hello
  1. Clone the code. git clone https://github.com/Azure-Samples/active-directory-javascript-graphapi-web-v2.git

  2. Inside index.html, replace Register your app at apps.dev.microsoft.com with the Application Id from the application registered in the Microsoft Application Registration Portal

  3. Run the web app on port 8000, and navigate to http://localhost:8000. If you have Python installed you can run a simple web server with the following command,

  python -m SimpleHTTPServer 8000

You should be able to click on a login button to sign in with your AAD or MSA account. Once you sign in, the authentication response containing the requested token is displayed.

Community Help and Support

Please file any questions or problems with the sample as GitHub Issues. You can also post on Stack Overflow with the tag [azure-active-directory]. We highly recommend you ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before.

For the OAuth2.0 library issues, please direct issues and feature requests to the library's open-source project.

This sample was tested with hello.js v1.16.1, Google Chrome version 64.0, and macOS 10.13.

Acknowledgements

This sample was adapted from the hello.js templates. Thanks to Brandon Werner for doing the initial testing and preparing much of the code.

その他のサンプル (提供: Navya Canumalla)