|
3 | 3 | import { IPublicClientApplication } from "@azure/msal-browser";
|
4 | 4 |
|
5 | 5 | const appServicesAuthTokenUrl = ".auth/me";
|
| 6 | +const appServicesAuthTokenRefreshUrl = ".auth/refresh"; |
6 | 7 | const appServicesAuthLogoutUrl = ".auth/logout?post_logout_redirect_uri=/";
|
7 | 8 |
|
8 | 9 | interface AppServicesToken {
|
@@ -88,18 +89,24 @@ export const getRedirectUri = () => {
|
88 | 89 | // Get an access token if a user logged in using app services authentication
|
89 | 90 | // Returns null if the app doesn't support app services authentication
|
90 | 91 | const getAppServicesToken = (): Promise<AppServicesToken | null> => {
|
91 |
| - return fetch(appServicesAuthTokenUrl).then(r => { |
| 92 | + return fetch(appServicesAuthTokenRefreshUrl).then(r => { |
92 | 93 | if (r.ok) {
|
93 |
| - return r.json().then(json => { |
94 |
| - if (json.length > 0) { |
95 |
| - return { |
96 |
| - id_token: json[0]["id_token"] as string, |
97 |
| - access_token: json[0]["access_token"] as string, |
98 |
| - user_claims: json[0]["user_claims"].reduce((acc: Record<string, any>, item: Record<string, any>) => { |
99 |
| - acc[item.typ] = item.val; |
100 |
| - return acc; |
101 |
| - }, {}) as Record<string, any> |
102 |
| - }; |
| 94 | + return fetch(appServicesAuthTokenUrl).then(r => { |
| 95 | + if (r.ok) { |
| 96 | + return r.json().then(json => { |
| 97 | + if (json.length > 0) { |
| 98 | + return { |
| 99 | + id_token: json[0]["id_token"] as string, |
| 100 | + access_token: json[0]["access_token"] as string, |
| 101 | + user_claims: json[0]["user_claims"].reduce((acc: Record<string, any>, item: Record<string, any>) => { |
| 102 | + acc[item.typ] = item.val; |
| 103 | + return acc; |
| 104 | + }, {}) as Record<string, any> |
| 105 | + }; |
| 106 | + } |
| 107 | + |
| 108 | + return null; |
| 109 | + }); |
103 | 110 | }
|
104 | 111 |
|
105 | 112 | return null;
|
|
0 commit comments