Coder Social home page Coder Social logo

mylescarrick / ms-identity-javascript-nodejs-console Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/ms-identity-javascript-nodejs-console

0.0 1.0 0.0 71 KB

A Node.js console daemon application secured by MSAL Node and calling Microsoft Graph API via OAuth 2.0 client credentials flow

License: MIT License

Shell 1.35% JavaScript 14.26% PowerShell 84.39%

ms-identity-javascript-nodejs-console's Introduction

page_type languages products description urlFragment
sample
javascript
nodejs
ms-graph
azure-active-directory
Demonstrates how to use MSAL Node to acquire an access token for a protected resource such as Microsoft Graph in a console application using the application's own identity (client credentials flow)
ms-identity-javascript-nodejs-console

A Node.js console application secured by MSAL Node on Microsoft identity platform

This sample demonstrates how to use MSAL Node to acquire an access token for a protected resource such as Microsoft Graph in a console application using the application's own identity with the (client credentials flow).

Features

This sample demonstrates the following MSAL Node concepts:

  • Configuration
  • Acquiring an access token
  • Calling a web API

Contents

File/folder Description
AppCreationScripts/ Contains Powershell scripts for automating app registration.
bin/index.js Application entry.
bin/auth.js Main authentication logic resides here.
bin/fetch.js Contains an Axios HTTP client for calling endpoints.
.env Environment variables of authentication parameters.

Getting Started

Prerequisites

Setup

  1. Register a new application in the Azure Portal.
    1. For API Permissions, select User.Read.All under Microsoft APIs > Microsoft Graph > Application Permissions.
    2. Select Grant admin consent for {tenant}.
  2. Clone this repository git clone https://github.com/Azure-Samples/ms-identity-javascript-nodejs-console.git
  3. Open the .env file and provide the required configuration values.
    1. Replace the string Enter_the_Tenant_Info_Here with your tenant ID on Azure AD portal.
    2. Replace the string Enter_the_Application_Id_Here with your app/client ID on Azure AD portal.
    3. Replace the string Enter_the_Client_Secret_Here with the client secret you created on Azure AD portal.
    4. Replace the string Enter_the_Cloud_Instance_Id_Here with https://login.microsoftonline.com/ (see note below).
    5. Replace the string Enter_the_Graph_Endpoint_Here. with https://graph.microsoft.com/ (see note below).

ℹ️ note: This is for multi-tenant applications located on the global Azure cloud. For more information, see: Use MSAL in a national cloud environment

ℹ️ note: This is for MS Graph instance located on the global Azure cloud. For more information, see: Use Microsoft Graph in a national cloud environment

  1. On the command line, navigate to the root of the repository, and type npm install.

ℹ️ Alternative, type npm install -g. This will install the CLI application globally so that it can be called from anywhere.

Run the sample

  1. On the command line, navigate to the root of the repository and run the sample application with node . --op getUsers.

ℹ️ If you have installed the sample app globally above, type msal-node-cli --op getUsers from anywhere in a command line.

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.MD.

Code of Conduct

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.

ms-identity-javascript-nodejs-console's People

Contributors

derisen avatar idg-sam avatar microsoft-github-operations[bot] avatar microsoftopensource avatar salman90 avatar sameerag avatar

Watchers

 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.