Collection level
- Open the collection settings and navigate to the Auth tab.
-
Select
OAuth 2.0as the authentication method and set the grant type toClient Credentials. Fill in the necessary fields with the relevant information. - In the Scripts tab, add the following script to the post-response section:
access_token value from the response body to a runtime variable named access_token_set_by_collection_script, making it available for use in all requests within the collection. You can adjust this script to suit your needs.
- Return to the Auth tab and click the ‘Get Access Token’ button. You are now free to use the token stored in the
access_token_set_by_collection_scriptruntime variable in your requests as needed.
Request level
- Create a new empty request and navigate to the Auth tab.
-
Select
Oauth 2.0as the authentication method and set the grant type toClient Credentials. Fill in the necessary fields with the relevant information. - In the Scripts tab, add the following script to the post-response section:
access_token value from the response body to a runtime variable named access_token_set_by_request_script, making it available for use in all requests within the collection. You can adjust this script to suit your needs.
- Return to the Auth tab and click the ‘Get Access Token’ button. You are now free to use the token stored in the
access_token_set_by_request_scriptruntime variable in your requests as needed.