Skip to content

Commit 687ae90

Browse files
committed
Update JWT to Bearer, this is backwards compatible.
1 parent 45df59b commit 687ae90

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/FusionAuthClient.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,9 @@ export class FusionAuthClient {
10811081
* @returns {Promise<ClientResponse<SecretResponse>>}
10821082
*/
10831083
generateTwoFactorSecretUsingJWT(encodedJWT: string): Promise<ClientResponse<SecretResponse>> {
1084-
return this.start<SecretResponse, void>()
1084+
return this.startAnonymous<SecretResponse, void>()
10851085
.withUri('/api/two-factor/secret')
1086-
.withAuthorization('JWT ' + encodedJWT)
1086+
.withAuthorization('Bearer ' + encodedJWT)
10871087
.withMethod("GET")
10881088
.go();
10891089
}
@@ -1196,9 +1196,9 @@ export class FusionAuthClient {
11961196
* @returns {Promise<ClientResponse<IssueResponse>>}
11971197
*/
11981198
issueJWT(applicationId: UUID, encodedJWT: string, refreshToken: string): Promise<ClientResponse<IssueResponse>> {
1199-
return this.start<IssueResponse, Errors>()
1199+
return this.startAnonymous<IssueResponse, Errors>()
12001200
.withUri('/api/jwt/issue')
1201-
.withAuthorization('JWT ' + encodedJWT)
1201+
.withAuthorization('Bearer ' + encodedJWT)
12021202
.withParameter('applicationId', applicationId)
12031203
.withParameter('refreshToken', refreshToken)
12041204
.withMethod("GET")
@@ -2772,7 +2772,7 @@ export class FusionAuthClient {
27722772
retrieveUserUsingJWT(encodedJWT: string): Promise<ClientResponse<UserResponse>> {
27732773
return this.startAnonymous<UserResponse, Errors>()
27742774
.withUri('/api/user')
2775-
.withAuthorization('JWT ' + encodedJWT)
2775+
.withAuthorization('Bearer ' + encodedJWT)
27762776
.withMethod("GET")
27772777
.go();
27782778
}
@@ -3393,6 +3393,21 @@ export class FusionAuthClient {
33933393
.go();
33943394
}
33953395

3396+
/**
3397+
* Call the UserInfo endpoint to retrieve User Claims from the access token issued by FusionAuth.
3398+
*
3399+
* @param {string} encodedJWT The encoded JWT (access token).
3400+
* @returns {Promise<ClientResponse<UserResponse>>}
3401+
*/
3402+
userInfo(encodedJWT: string): Promise<ClientResponse<UserResponse>> {
3403+
return this.startAnonymous<UserResponse, OAuthError>()
3404+
.withHeader('Content-Type', 'text/plain')
3405+
.withUri('/oauth2/userinfo')
3406+
.withAuthorization('Bearer ' + encodedJWT)
3407+
.withMethod("POST")
3408+
.go();
3409+
}
3410+
33963411
/**
33973412
* Validates the end-user provided user_code from the user-interaction of the Device Authorization Grant.
33983413
* If you build your own activation form you should validate the user provided code prior to beginning the Authorization grant.
@@ -3422,7 +3437,7 @@ export class FusionAuthClient {
34223437
validateJWT(encodedJWT: string): Promise<ClientResponse<ValidateResponse>> {
34233438
return this.startAnonymous<ValidateResponse, void>()
34243439
.withUri('/api/jwt/validate')
3425-
.withAuthorization('JWT ' + encodedJWT)
3440+
.withAuthorization('Bearer ' + encodedJWT)
34263441
.withMethod("GET")
34273442
.go();
34283443
}

0 commit comments

Comments
 (0)