In the OAuth 2.0 Authorization Code flow, what is the main purpose of the authorization code?
Think about why the authorization code is exchanged for an access token instead of using it directly.
The authorization code is a temporary code that the client receives after user authorization. It is exchanged securely for an access token, which is then used to access protected resources. This prevents exposing user credentials or tokens in the browser.
Given this Postman OAuth 2.0 token request setup, what will be the result if the client_id or client_secret is incorrect?
POST /oauth/token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
client_id=wrong_id&client_secret=wrong_secret&grant_type=authorization_code&code=abc123&redirect_uri=https://app.example.com/callbackConsider what happens when client credentials are wrong during token exchange.
If the client_id or client_secret is incorrect, the authorization server responds with an 'invalid_client' error indicating client authentication failure.
Which Postman test script assertion correctly verifies that the access token is present and is a non-empty string in the OAuth 2.0 token response?
pm.test("Access token is present and valid", function () {
const jsonData = pm.response.json();
// Assertion goes here
});Check for type string and that it is not empty.
Option B correctly asserts that the access_token exists, is a string, and is not empty. Option B incorrectly checks if it equals true. Option B expects it to be undefined which is wrong. Option B checks length but does not verify type or presence.
You have a Postman test script that checks if the access token expires in less than 5 minutes and fails the test if so. The script is:
pm.test("Token expiry is sufficient", function () {
const jsonData = pm.response.json();
pm.expect(jsonData.expires_in & 300).to.be.true;
});What is the issue with this script?
Look carefully at the operator used in the assertion.
The script uses the bitwise AND operator (&) instead of the greater than operator (>). This causes the expression to evaluate incorrectly, leading to wrong test results.
Which approach correctly automates the OAuth 2.0 Authorization Code flow in Postman Collection Runner to obtain and use access tokens dynamically?
Think about how to automate token retrieval and usage dynamically in Postman scripts.
Option A describes the correct automation approach: using pre-request scripts to programmatically obtain the authorization code and exchange it for an access token, then saving it for use in requests. Other options rely on manual or static token usage, which is not automation.