Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the authentication method used between microservices.
Microservices
auth_method = "[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing BasicAuth which is less secure for service-to-service communication.
Using None which means no authentication.
✗ Incorrect
OAuth2 is a widely used standard for service-to-service authentication in microservices.
2fill in blank
mediumComplete the code to define the token type used in service authentication.
Microservices
token_type = "[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Basic which is for username-password authentication.
Using Digest or MAC which are less common in microservices.
✗ Incorrect
Bearer tokens are commonly used in OAuth2 for service-to-service authentication.
3fill in blank
hardFix the error in the code to correctly validate the token expiration time.
Microservices
if current_time > token.[1]:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'issued_at' which is when the token was created, not expiration.
Using 'valid_until' which is not a standard field.
✗ Incorrect
Token expiration is checked against the 'expires_at' timestamp.
4fill in blank
hardFill both blanks to complete the token validation logic.
Microservices
if token.[1] and token.[2] == True:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is_expired' which should be False for valid tokens.
Using 'is_revoked' which should be False for valid tokens.
✗ Incorrect
Tokens must be active and valid to be accepted.
5fill in blank
hardFill all three blanks to complete the service-to-service authentication flow.
Microservices
token = auth_server.get_token(client_id=[1], client_secret=[2]) headers = {"Authorization": "[3] " + token} response = service.call_api(headers=headers)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Basic' instead of 'Bearer' in the header.
Mixing client ID and secret values.
✗ Incorrect
The client ID and secret are used to get the token, which is sent with 'Bearer' in the Authorization header.