File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -88,33 +88,32 @@ export class KeycloakService {
88
88
}
89
89
90
90
async refreshGrant ( ) : Promise < TokenSet | undefined | null > {
91
- if ( this . tokenSet && ! this . tokenSet . expired ( ) ) {
92
- return this . tokenSet
93
- }
94
-
95
91
if ( ! this . tokenSet ) {
96
- this . logger . warn ( `Missing token set on refreshGrant.` )
97
- return null
92
+ await this . initialize ( )
98
93
}
99
94
100
- const { refresh_token } = this . tokenSet
95
+ if ( ! this . tokenSet ?. expired ( ) ) {
96
+ return this . tokenSet
97
+ }
101
98
102
- if ( ! refresh_token ) {
99
+ if ( ! this . tokenSet . refresh_token ) {
103
100
this . logger . debug ( `Refresh token is missing. Reauthenticating.` )
104
101
105
102
this . tokenSet = await this . issuerClient ?. grant ( {
106
103
clientId : this . options . clientId ,
107
104
clientSecret : this . options . clientSecret ,
108
105
grant_type : 'client_credentials' ,
109
106
} )
110
- if ( this . tokenSet ?. access_token ) this . client . setAccessToken ( this . tokenSet ?. access_token )
107
+ if ( this . tokenSet ?. access_token ) {
108
+ this . client . setAccessToken ( this . tokenSet ?. access_token )
109
+ }
111
110
112
111
return this . tokenSet
113
112
}
114
113
115
114
this . logger . debug ( `Refreshing grant token` )
116
115
117
- this . tokenSet = await this . issuerClient ?. refresh ( refresh_token )
116
+ this . tokenSet = await this . issuerClient ?. refresh ( this . tokenSet . refresh_token )
118
117
119
118
return this . tokenSet
120
119
}
You can’t perform that action at this time.
0 commit comments