Complete the code to specify the OAuth 2.0 grant type in Postman.
pm.environment.set('grant_type', '[1]');
The authorization_code grant type is used to obtain an access token via an authorization code in OAuth 2.0 flow.
Complete the code to set the token URL for OAuth 2.0 in Postman.
pm.environment.set('token_url', '[1]');
The token URL is where Postman sends the request to exchange the authorization code for an access token.
Fix the error in the code to correctly set the client ID in Postman environment.
pm.environment.set('client_id', [1]);
The client ID must be a string, so it needs to be enclosed in quotes when setting in Postman environment.
Fill both blanks to correctly extract and save the access token from the OAuth 2.0 response in Postman.
const response = pm.response.json(); pm.environment.set('[1]', response.[2]);
The access token is usually found in the access_token field of the OAuth 2.0 response JSON.
Fill all three blanks to create a test in Postman that checks if the OAuth 2.0 access token is present and valid.
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); });
This test checks that the access_token exists, is a string, and has a length greater than 10 characters, indicating a valid token.