-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
var msal = require("@azure/msal-node"); | ||
|
||
const msalConfig = { | ||
auth: { | ||
clientId: "", // Enter your client_id here | ||
authority: "", // Enter your authority here | ||
clientSecret: "" // Enter your client_secret here | ||
} | ||
}; | ||
|
||
const cca = new msal.ConfidentialClientApplication(msalConfig); | ||
|
||
const usernamePasswordRequest = { | ||
scopes: ["user.read"], | ||
username: "", // Add your username here | ||
password: "", // Add your password here | ||
}; | ||
|
||
cca.acquireTokenByUsernamePassword(usernamePasswordRequest).then((response) => { | ||
console.log("acquired token by password grant in confidential clients"); | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
|
||
|
||
|
18 changes: 18 additions & 0 deletions
18
samples/msal-node-samples/username-password-cca/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "msal-node-username-password-cca", | ||
"version": "1.0.0", | ||
"description": "Command line app that uses Oauth password grant flow to get a token from Azure AD", | ||
"main": "index.js", | ||
"private": true, | ||
"scripts": { | ||
"start": "node index.js", | ||
"build:package": "cd ../../lib/msal-common && npm run build && cd ../msal-node && npm run build", | ||
"start:build": "npm run build:package && npm start", | ||
"install:local": "npm install ../../../lib/msal-node" | ||
}, | ||
"author": "Microsoft", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@azure/msal-node": "file:../../../lib/msal-node" | ||
} | ||
} |