1
- import request from ' request' ;
1
+ import request from " request" ;
2
2
3
3
const client_secret = process . env . AadClientSecret ;
4
4
if ( ! client_secret ) {
5
- console . error ( "Did not find client secret in environment." ) ;
6
- process . exit ( 1 ) ;
5
+ console . error ( "Did not find client secret in environment." ) ;
6
+ process . exit ( 1 ) ;
7
7
}
8
8
9
9
var options = {
10
- ' method' : ' POST' ,
11
- ' url' : ' https://login.microsoftonline.com/c8d9148f-9a59-4db3-827d-42ea0c2b6e2e/oauth2/token' ,
12
- ' headers' : {
13
- ' Content-Type' : ' application/x-www-form-urlencoded' ,
14
- ' Cookie' : 'esctx=PAQABBwEAAAApTwJmzXqdR4BN2miheQMYx8m4odNFiSkFXBDxAsyDVihl0yV2geMRVf-xYZ_GI34ZgJzPlzsLI4IyGrHFUcRyt_kOrGgfKtxKD_l8Shb9DAyh2xT4JeGXJhIyqsMO-lMmpvDuGjePONePVhmPE4TzQuQUh6V8Y4yWwBV10HljcSWz0Jp0DGs5MB4wMCl3CVwgAA; fpc=Asmn40XcT3RJkq8G_zKhA64gJa0wAQAAANHbRN4OAAAADPYZNQMAAADZ20TeDgAAABa8tnsBAAAAeN1E3g4AAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd'
15
- } ,
16
- form : {
17
- 'grant_type' : 'client_credentials' ,
18
- 'client_id' : '519866d4-45a8-44ae-9925-9fb61b85074e' ,
19
- 'client_secret' : client_secret ,
20
- 'resource' : 'api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296' ,
21
- 'scope' : ' api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296/ACM.Events.Login'
22
- }
23
- } ;
24
- request ( options , function ( error , response ) {
25
- if ( error ) throw new Error ( error ) ;
26
- console . log ( JSON . parse ( response . body ) [ 'access_token' ] ) ;
27
- } ) ;
28
-
10
+ method : " POST" ,
11
+ url : " https://login.microsoftonline.com/c8d9148f-9a59-4db3-827d-42ea0c2b6e2e/oauth2/token" ,
12
+ headers : {
13
+ " Content-Type" : " application/x-www-form-urlencoded" ,
14
+ Cookie :
15
+ "esctx=PAQABBwEAAAApTwJmzXqdR4BN2miheQMYx8m4odNFiSkFXBDxAsyDVihl0yV2geMRVf-xYZ_GI34ZgJzPlzsLI4IyGrHFUcRyt_kOrGgfKtxKD_l8Shb9DAyh2xT4JeGXJhIyqsMO-lMmpvDuGjePONePVhmPE4TzQuQUh6V8Y4yWwBV10HljcSWz0Jp0DGs5MB4wMCl3CVwgAA; fpc=Asmn40XcT3RJkq8G_zKhA64gJa0wAQAAANHbRN4OAAAADPYZNQMAAADZ20TeDgAAABa8tnsBAAAAeN1E3g4AAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd" ,
16
+ } ,
17
+ form : {
18
+ grant_type : "client_credentials" ,
19
+ client_id : "519866d4-45a8-44ae-9925-9fb61b85074e" ,
20
+ client_secret : client_secret ,
21
+ resource : " api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296" ,
22
+ scope : "api://5e08cf0f-53bb-4e09-9df2-e9bdc3467296/ACM.Events.Login" ,
23
+ } ,
24
+ } ;
25
+ request ( options , function ( error , response ) {
26
+ if ( error ) throw new Error ( error ) ;
27
+ console . log ( JSON . parse ( response . body ) [ "access_token" ] ) ;
28
+ } ) ;
0 commit comments