All Projects → Azure-Samples → ms-identity-javascript-v2

Azure-Samples / ms-identity-javascript-v2

Licence: MIT license
VanillaJS sample using MSAL.js v2.x and OAuth 2.0 Authorization Code Flow with PKCE on Microsoft identity platform

Programming Languages

javascript
184084 projects - #8 most used programming language
powershell
5483 projects
HTML
75241 projects

Projects that are alternatives of or similar to ms-identity-javascript-v2

schematics
Schematics for adding Okta Auth to your projects
Stars: ✭ 60 (-10.45%)
Mutual labels:  oauth2, pkce
ms-identity-javascript-react-tutorial
A chapterwise tutorial that will take you through the fundamentals of modern authentication with Microsoft identity platform in React using MSAL React
Stars: ✭ 100 (+49.25%)
Mutual labels:  oauth2, msal-js
pkce-generator
Code Verifier and Code Challenge Generator for OAuth with PKCE
Stars: ✭ 81 (+20.9%)
Mutual labels:  oauth2, pkce
ms-identity-javascript-tutorial
A chapterwise tutorial that will take you through the fundamentals of modern authentication with Microsoft identity platform in Vanilla JavaScript.
Stars: ✭ 100 (+49.25%)
Mutual labels:  single-page-application, msal-js
a12n-server
A ready-to-launch User and Authentication system for those that don't want to build it
Stars: ✭ 324 (+383.58%)
Mutual labels:  oauth2, pkce
ms-identity-javascript-react-spa-dotnetcore-webapi-obo
A React & Redux single-page application that authorizes an ASP.NET Core web API to call MS Graph API on-behalf-of a signed-in user.
Stars: ✭ 62 (-7.46%)
Mutual labels:  pkce, msal-js
lumen-oauth2
OAuth2 module for the Lumen PHP framework.
Stars: ✭ 29 (-56.72%)
Mutual labels:  oauth2
mock-oauth2-server
A scriptable/customizable web server for testing HTTP clients using OAuth2/OpenID Connect or applications with a dependency to a running OAuth2 server (i.e. APIs requiring signed JWTs from a known issuer)
Stars: ✭ 83 (+23.88%)
Mutual labels:  oauth2
oauth2-server
A spec compliant, secure by default PHP OAuth 2.0 Server
Stars: ✭ 6,128 (+9046.27%)
Mutual labels:  oauth2
ueberauth discord
Discord OAuth2 Strategy for Überauth.
Stars: ✭ 12 (-82.09%)
Mutual labels:  oauth2
jeesuite-passport
Jeesuite-passport是面向企业级单点登录、统一认证的一站式解决方案。支持微信、企业微信、主流开放平台OAuth、Oauth2.0,JWT、SAML2.0多种认证集成模式。
Stars: ✭ 108 (+61.19%)
Mutual labels:  oauth2
Facebook-Login-Xamarin-Forms
Demo for login to Facebook API from Xamarin Forms
Stars: ✭ 41 (-38.81%)
Mutual labels:  oauth2
VKontakte
[READ ONLY] Subtree split of the SocialiteProviders/VKontakte Provider (see SocialiteProviders/Providers)
Stars: ✭ 82 (+22.39%)
Mutual labels:  oauth2
oauthproxy
This is an oauth2 proxy server
Stars: ✭ 32 (-52.24%)
Mutual labels:  oauth2
IdentityServer4.PhoneNumberAuth
Sample passwordless phone number authentication using OAuth in ASP.NET Core 2.2
Stars: ✭ 83 (+23.88%)
Mutual labels:  oauth2
spring-boot-security-oauth2-google
Microservice using OAuth 2.0 and OpenID Connect to authenticate into Google and get information to a user.
Stars: ✭ 75 (+11.94%)
Mutual labels:  oauth2
ertis-auth
Generic token generator and validator service like auth
Stars: ✭ 28 (-58.21%)
Mutual labels:  oauth2
okta-spring-security-5-example
Authentication with Spring Security 5 and Okta OIDC
Stars: ✭ 16 (-76.12%)
Mutual labels:  oauth2
python-hydra-sdk
Hydra SDK for Python
Stars: ✭ 16 (-76.12%)
Mutual labels:  oauth2
native-java-examples
Native Java Apps with Micronaut, Quarkus, and Spring Boot
Stars: ✭ 44 (-34.33%)
Mutual labels:  oauth2
page_type languages products description urlFragment
sample
javascript
html
ms-graph
azure-active-directory
microsoft-identity-platform
A simple JavaScript Single-Page Application using the Auth Code flow w/ PKCE
ms-identity-javascript-v2

Vanilla JavaScript Single-page Application secured with MSAL.js

A simple vanilla JavaScript single-page application which demonstrates how to configure MSAL.JS 2.x to login, logout, and acquire an access token for a protected resource such as the Microsoft Graph API. This version of the MSAL.js library uses the authorization code flow with PKCE.

Note: A quickstart guide covering this sample can be found here.

Note: A more detailed tutorial covering this sample can be found here.

Contents

File/folder Description
app Contains sample source files
authPopup.js Main authentication logic resides here (using Popup flow).
authRedirect.js Use this instead of authPopup.js for authentication with redirect flow.
authConfig.js Contains configuration parameters for the sample.
graph.js Provides a helper function for calling MS Graph API.
graphConfig.js Contains API endpoints for MS Graph.
ui.js Contains UI logic.
index.html Contains the UI of the sample.
.gitignore Define what to ignore at commit time.
package.json Package manifest for npm.
server.js Implements a simple Node server to serve index.html.

Prerequisites

Node must be installed to run this sample.

Setup

  1. Register a new application in the Azure Portal. Ensure that the application is enabled for the authorization code flow with PKCE. This will require that you redirect URI configured in the portal is of type SPA.
  2. Open the /app/authConfig.js file and provide the required configuration values.
  3. On the command line, navigate to the root of the repository, and run npm install to install the project dependencies via npm.

Running the sample

  1. Configure authentication and authorization parameters:
    1. Open authConfig.js
    2. Replace the string "Enter_the_Application_Id_Here" with your app/client ID on AAD Portal.
    3. Replace the string "Enter_the_Cloud_Instance_Id_HereEnter_the_Tenant_Info_Here" with "https://login.microsoftonline.com/common/" (note: This is for multi-tenant applications located on the global Azure cloud. For more information, see the documentation).
    4. Replace the string "Enter_the_Redirect_Uri_Here" with the redirect uri you setup on AAD Portal.
  2. Configure the parameters for calling MS Graph API:
    1. Open graphConfig.js.
    2. Replace the string "Enter_the_Graph_Endpoint_Herev1.0/me" with "https://graph.microsoft.com/v1.0/me".
    3. Replace the string "Enter_the_Graph_Endpoint_Herev1.0/me/messages" with "https://graph.microsoft.com/v1.0/me/messages".
  3. To start the sample application, run npm start.
  4. Finally, open a browser and navigate to http://localhost:3000.

How did we do? Consider sharing your experience with us.

Key concepts

This sample demonstrates the following MSAL workflows:

  • How to configure application parameters.
  • How to sign-in with popup and redirect methods.
  • How to sign-out.
  • How to get user consent incrementally.
  • How to acquire an access token.
  • How to make an API call with the access token.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].