0
0
Postmantesting~10 mins

OAuth 2.0 flow in Postman - 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 in Postman.

Postman
pm.environment.set('grant_type', '[1]');
Drag options to blanks, or click blank then click option'
Aclient_credentials
Brefresh_token
Cpassword
Dauthorization_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using client_credentials grant type which is for server-to-server authentication.
Using password grant type which requires user credentials directly.
2fill in blank
medium

Complete the code to set the token URL for OAuth 2.0 in Postman.

Postman
pm.environment.set('token_url', '[1]');
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com/userinfo
Bhttps://api.example.com/token
Chttps://api.example.com/authorize
Dhttps://api.example.com/auth
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the authorize URL with the token URL.
Using userinfo endpoint as token URL.
3fill in blank
hard

Fix the error in the code to correctly set the client ID in Postman environment.

Postman
pm.environment.set('client_id', [1]);
Drag options to blanks, or click blank then click option'
A1234567890abcdef
B"1234567890abcdef"
C'1234567890abcdef'
Dclient_id_value
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the client ID string.
Using double quotes inside double quotes without escaping.
4fill in blank
hard

Fill both blanks to correctly extract and save the access token from the OAuth 2.0 response in Postman.

Postman
const response = pm.response.json();
pm.environment.set('[1]', response.[2]);
Drag options to blanks, or click blank then click option'
Aaccess_token
Btoken
CaccessToken
Dtoken_value
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'token' or 'accessToken' if the API uses 'access_token'.
Mismatching environment variable name and JSON property.
5fill in blank
hard

Fill all three blanks to create a test in Postman that checks if the OAuth 2.0 access token is present and valid.

Postman
pm.test('Access token is present', () => {
  const jsonData = pm.response.json();
  pm.expect(jsonData.[1]).to.be.a('[2]');
  pm.expect(jsonData.[3].length).to.be.greaterThan(10);
});
Drag options to blanks, or click blank then click option'
Aaccess_token
Bstring
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names like 'token' instead of 'access_token'.
Checking for wrong data types or missing length check.