Skip to content

Commit

Permalink
add get_msft_jwt script
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Aug 7, 2024
1 parent 2748daf commit 7a6a7ab
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 4 deletions.
28 changes: 28 additions & 0 deletions get_msft_jwt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import request from 'request';

const client_secret = process.env.EVENTS_API_CLIENT_SECRET;
if (!client_secret) {
console.error("Did not find client secret in environment.");
process.exit(1);
}

var options = {
'method': 'POST',
'url': 'https://login.microsoftonline.com/c8d9148f-9a59-4db3-827d-42ea0c2b6e2e/oauth2/token',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'esctx=PAQABBwEAAAApTwJmzXqdR4BN2miheQMYx8m4odNFiSkFXBDxAsyDVihl0yV2geMRVf-xYZ_GI34ZgJzPlzsLI4IyGrHFUcRyt_kOrGgfKtxKD_l8Shb9DAyh2xT4JeGXJhIyqsMO-lMmpvDuGjePONePVhmPE4TzQuQUh6V8Y4yWwBV10HljcSWz0Jp0DGs5MB4wMCl3CVwgAA; fpc=Asmn40XcT3RJkq8G_zKhA64gJa0wAQAAANHbRN4OAAAADPYZNQMAAADZ20TeDgAAABa8tnsBAAAAeN1E3g4AAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd'
},
form: {
'grant_type': 'client_credentials',
'client_id': '519866d4-45a8-44ae-9925-9fb61b85074e',
'client_secret': client_secret,
'resource': 'api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296',
'scope': 'api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296/ACM.Events.Login'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(JSON.parse(response.body)['access_token']);
});

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
"request": "^2.88.2",
"synp": "^1.9.13",
"tsx": "^4.16.5",
"typescript": "^5.5.4"
Expand Down
Loading

0 comments on commit 7a6a7ab

Please sign in to comment.