1
1
import { AuthConfig } from 'angular-oauth2-oidc' ;
2
2
3
+ // Set this to true, to use silent refresh; otherwise the example
4
+ // uses the refresh_token via an AJAX coll to get new tokens.
5
+ const useSilentRefresh = false ;
6
+
3
7
export const authCodeFlowConfig : AuthConfig = {
4
8
issuer : 'https://idsvr4.azurewebsites.net' ,
5
9
@@ -9,8 +13,6 @@ export const authCodeFlowConfig: AuthConfig = {
9
13
? '/#/index.html'
10
14
: '/index.html' ) ,
11
15
12
- silentRefreshRedirectUri : `${ window . location . origin } /silent-refresh.html` ,
13
-
14
16
// The SPA's id. The SPA is registerd with this id at the auth-server
15
17
// clientId: 'server.code',
16
18
clientId : 'spa' ,
@@ -27,16 +29,25 @@ export const authCodeFlowConfig: AuthConfig = {
27
29
// The first four are defined by OIDC.
28
30
// Important: Request offline_access to get a refresh token
29
31
// The api scope is a usecase specific one
30
- scope : 'openid profile email offline_access api' ,
32
+ scope : ( useSilentRefresh ) ?
33
+ 'openid profile email api' :
34
+ 'openid profile email offline_access api' ,
31
35
32
- showDebugInformation : true ,
36
+ // ^^ Please note that offline_access is not needed for silent refresh
37
+ // At least when using idsvr, this even prevents silent refresh
38
+ // as idsvr ALWAYS prompts the user for consent when this scope is
39
+ // requested
33
40
34
- // If you specify this property, the lib tries to refresh the
35
- // token via a silet refresh; otherwise it sends over a refresh_token
36
- // via an AJAX call to get new tokens.
37
- silentRefreshRedirectUri : window . location . origin + ' /silent-refresh.html' ,
41
+ // This is needed for silent refresh (refreshing tokens w/o a refresh_token)
42
+ // **AND** for logging in with a popup
43
+ silentRefreshRedirectUri :
44
+ ` ${ window . location . origin } /silent-refresh.html` ,
38
45
46
+ useSilentRefresh : useSilentRefresh ,
39
47
40
- timeoutFactor : 0.01
48
+ showDebugInformation : true ,
49
+
50
+ timeoutFactor : 0.01 ,
41
51
// disablePKCI: true,
52
+
42
53
} ;
0 commit comments