0
0
Spring Bootframework~10 mins

Refresh token pattern in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a refresh token field in a Spring Boot entity.

Spring Boot
private String [1];
Drag options to blanks, or click blank then click option'
AtokenExpiry
BaccessToken
CuserId
DrefreshToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'accessToken' instead of 'refreshToken'.
Naming the field unrelated to tokens.
2fill in blank
medium

Complete the code to generate a new refresh token string using UUID.

Spring Boot
String newRefreshToken = UUID.[1]().toString();
Drag options to blanks, or click blank then click option'
ArandomUUID
BnewUUID
CgenerateUUID
DcreateUUID
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'newUUID()'.
Confusing with other UUID methods.
3fill in blank
hard

Fix the error in the method signature for refreshing tokens in a Spring Boot controller.

Spring Boot
public ResponseEntity<?> [1](@RequestBody TokenRefreshRequest request) {
Drag options to blanks, or click blank then click option'
ArefreshAccessToken
BrefreshToken
CgetToken
DupdateToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague method names like 'getToken'.
Using names that do not indicate refreshing.
4fill in blank
hard

Fill both blanks to complete the code that validates the refresh token and generates a new access token.

Spring Boot
if (tokenService.validate[1](request.get[2]())) {
    String accessToken = tokenService.createAccessToken();
}
Drag options to blanks, or click blank then click option'
ARefreshToken
BAccessToken
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing access token and refresh token in validation.
Using incorrect method names.
5fill in blank
hard

Fill all three blanks to complete the code that creates a response with the new access token, refresh token, and token type.

Spring Boot
return ResponseEntity.ok(new TokenRefreshResponse([1], [2], [3]));
Drag options to blanks, or click blank then click option'
AaccessToken
B"Bearer"
CrefreshToken
D"Token"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping access token and refresh token positions.
Using incorrect token type strings.