0
0
Rest APIprogramming~10 mins

OAuth 2.0 overview in Rest API - Interactive Code Practice

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

Complete the code to specify the OAuth 2.0 grant type for client credentials.

Rest API
grant_type=[1]
Drag options to blanks, or click blank then click option'
Aauthorization_code
Brefresh_token
Cclient_credentials
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'authorization_code' when no user is involved.
Confusing 'password' grant type with client credentials.
2fill in blank
medium

Complete the code to include the access token in the HTTP Authorization header.

Rest API
Authorization: Bearer [1]
Drag options to blanks, or click blank then click option'
Arefresh_token
Baccess_token
Cclient_id
Dcode
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'client_id' instead of the token.
Sending the refresh token in the Authorization header.
3fill in blank
hard

Fix the error in the OAuth 2.0 token request URL by completing the missing query parameter.

Rest API
https://auth.example.com/token?grant_type=[1]&client_id=abc123
Drag options to blanks, or click blank then click option'
Aauthorization_code
Brefresh
Cclient_credentials
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'refresh' instead of 'refresh_token'.
Confusing 'client_credentials' with 'authorization_code'.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps scopes to their descriptions only if the scope length is greater than 5.

Rest API
scope_descriptions = [1]: descriptions[[2]] for [1] in scopes if len([1]) > 5}
Drag options to blanks, or click blank then click option'
Ascope
Bscopes
Cdescription
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and value.
Using the list name instead of the loop variable.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps user IDs to their tokens only if the token is not expired.

Rest API
valid_tokens = [1]: [2] for [1], [2] in user_tokens.items() if not [2].expired
Drag options to blanks, or click blank then click option'
Auser_id
Btoken
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names between key and value.
Using the wrong attribute to check expiration.