This repository has been archived by the owner. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +22
-26
lines changed
Expand file tree Collapse file tree 7 files changed +22
-26
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,18 @@ function callApiWithAccessToken(endpoint, token) {
1717 } ) . catch ( error => {
1818 logMessage ( "Error calling the Web api:\n" + error ) ;
1919 } ) ;
20+ }
21+
22+ //calls the resource API with the token
23+ function callApi ( ) {
24+ getTokenPopup ( tokenRequest )
25+ . then ( tokenResponse => {
26+ console . log ( 'access_token acquired at: ' + new Date ( ) . toString ( ) ) ;
27+ try {
28+ logMessage ( "Request made to Web API:" )
29+ callApiWithAccessToken ( apiConfig . webApi , tokenResponse . accessToken ) ;
30+ } catch ( err ) {
31+ console . log ( err ) ;
32+ }
33+ } ) ;
2034}
Original file line number Diff line number Diff line change 11const msalConfig = {
22 auth : {
3- clientId : "e760cab2-b9a1-4c0d-86fb-ff7084abd902" , //This is your client ID
4- authority : "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/" + b2cPolicies . signUpSignIn , //This is your tenant info
3+ clientId : "e760cab2-b9a1-4c0d-86fb-ff7084abd902" ,
4+ authority : "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/b2c_1_susi" ,
55 validateAuthority : false
66 } ,
77 cache : {
Original file line number Diff line number Diff line change @@ -36,18 +36,4 @@ function getTokenPopup(request) {
3636 console . log ( error ) ;
3737 } ) ;
3838 } ) ;
39- }
40-
41- //calls the resource API with the token
42- function callApi ( ) {
43- getTokenPopup ( tokenRequest )
44- . then ( tokenResponse => {
45- console . log ( 'access_token acquired at: ' + new Date ( ) . toString ( ) ) ;
46- try {
47- logMessage ( "Request made to Web API:" )
48- callApiWithAccessToken ( apiConfig . webApi , tokenResponse . accessToken ) ;
49- } catch ( err ) {
50- console . log ( err ) ;
51- }
52- } ) ;
5339}
Original file line number Diff line number Diff line change 33const myMSALObj = new Msal . UserAgentApplication ( msalConfig ) ;
44
55let accessToken ;
6+
67// Register Callbacks for Redirect flow
78myMSALObj . handleRedirectCallback ( authRedirectCallBack ) ;
89
Original file line number Diff line number Diff line change 2020</ head >
2121
2222< body >
23+
24+ <!-- Navbar -->
2325 < nav class ="navbar navbar-expand-lg navbar-dark bg-primary ">
2426 < a class ="navbar-brand " href ="/ "> Azure AD B2C</ a >
2527 < div class ="btn-group ml-auto dropleft ">
2628 < button type ="button " id ="signIn " class ="btn btn-secondary " onclick ="signIn() "> Sign In</ button >
2729 < button type ="button " id ="signOut " class ="btn btn-success " onclick ="logout() " style ="display:none "> Sign Out</ button >
2830 </ div >
2931 </ nav >
32+
33+ <!-- Content -->
3034 < div class ="card ">
3135 < h5 class ="card-header text-center "> Getting an access token with Azure AD B2C and calling a Web API</ h5 >
3236 < div class ="card-body text-center ">
@@ -42,12 +46,10 @@ <h5 id="label" class="card-title">Sign-in with Microsoft Azure AD B2C</h5>
4246 < script src ="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js " integrity ="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6 " crossorigin ="anonymous "> </ script >
4347
4448 <!-- importing app scripts -->
45- < script type ="text/javascript " src ="./policies.js "> </ script >
4649 < script type ="text/javascript " src ="./authConfig.js "> </ script >
4750 < script type ="text/javascript " src ="./apiConfig.js "> </ script >
4851 < script type ="text/javascript " src ="./ui.js "> </ script >
49-
50- <!-- replace with authRedirect if you would like to use redirect flow -->
52+ <!-- replace next with authRedirect if you would like to use redirect flow -->
5153 < script type ="text/javascript " src ="./authPopup.js "> </ script >
5254 < script type ="text/javascript " src ="./api.js "> </ script >
5355</ body >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11// UI elements to work with
22const signInButton = document . getElementById ( 'signIn' ) ;
33const signOutButton = document . getElementById ( 'signOut' ) ;
4-
54const callWebApiButton = document . getElementById ( 'callApiButton' ) ;
6-
75const label = document . getElementById ( 'label' ) ;
86const response = document . getElementById ( "response" ) ;
97
You can’t perform that action at this time.
0 commit comments