# Offers Merchant Content OAuth 2.0 authentication and first call source: https://developer.mastercard.com/eop-admin/documentation/tutorials-and-guides/offers-merchant-content-authentication-first-call-tutorial/index.md ## Introduction {#introduction} This tutorial describes how to install and configure the Mastercard Insomnia plugin, set up OAuth 2.0 authentication, and send your first successful Offers Merchant Content API request. ## Tutorial prerequisites {#tutorial-prerequisites} To complete this tutorial, you will need: * Insomnia installed on your local machine. * Mastercard Insomnia plugin installed in Insomnia. * Access to the Offers Merchant Content API Reference, including the OpenAPI specification file. * A Mastercard Developers Portal account with access to the Offers Merchant Content API APIs. * OAuth 2.0 credentials from the Mastercard Developers Portal: * Client ID * Key ID (kid) * OAuth scopes * Authentication key provided as a `.p12` keystore file, including its alias and password * Access to a Sandbox or Production environment, depending on where you are testing. ## Install and configure Insomnia {#install-and-configure-insomnia} ### Steps {#steps} 1. Install Insomnia from [here](https://github.com/Mastercard/insomnia-plugin-mastercard/blob/main/README.md#installation-). 2. Configure your Insomnia automatically [here](https://github.com/Mastercard/insomnia-plugin-mastercard/blob/main/README.md#configuration-). ### Environment configuration notes {#environment-configuration-notes} * Use the correct values according to the environment. * Keep only one authentication mode configured at a time (OAuth 2.0 or OAuth 1.0).
OAuth 2.0 token endpoint URL * Sandbox * Production ```Sandbox https://sandbox.api.mastercard.com/oauth/token ``` ```Production https://api.mastercard.com/oauth/token ``` Authorization server issuer URL * Sandbox * Production ```Sandbox https://sandbox.api.mastercard.com ``` ```Production https://api.mastercard.com ```
## Update required values {#update-required-values} ### Prerequisites {#prerequisites} For this step, you will need the following information from the Mastercard Developers portal: * Client ID * Key ID (kid) * Scopes * Authentication Key (`.p12` keystore file with its alias and password) ![alt text](https://static.developer.mastercard.com/content/eop-admin/uploads/mastercard-developers-offers-merchant-content.png "Mastercard Developers Portal") ### Steps {#steps-1} 1. Update the following values in your environment. | Value | Description | |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| | clientId | OAuth 2.0 client identifier. | | kid | Key ID of the client authentication key. | | keystoreP12Path | Absolute path to the P12 keystore file. | | keyAlias | Key alias within the P12 keystore. | | keystorePassword | Password for the P12 keystore. | | tokenEndpoint | OAuth 2.0 token endpoint URL. - Sandbox: - Production: | | issuer | Authorization server issuer URL. - Sandbox: - Production: | | scopes | Array of OAuth scopes to request. | ## Configure and send an API request {#configure-and-send-an-api-request} ### Option 1: Auto configuration {#option-1-auto-configuration} 1. Select a simple read endpoint from the [Offers Merchant Content API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/) page. #### Example from Offers Merchant Content API: {#example-from-offers-merchant-content-api} * GET /sources * Set the base url/domain for Sandbox: * Set the base url/domain for Production: #### Sample request URL: {#sample-request-url} 2. Build the request in Insomnia: * Create a new GET request with your endpoint URL. * Do not manually add the Authorization header. * Send the request. ### Option 2: Manual configuration {#option-2-manual-configuration} 1. Send a request using any API listed. ## Validate response {#validate-response} 1. Confirm that the request was successful by verifying: * HTTP 200 response or expected business status * Response payload from the API * The plugin applies the Authorization headers * No scope or permission errors occurred Tip: The following information explains how the Mastercard Insomnia plugin handles authentication and what a successful API response indicates. * The Mastercard Insomnia plugin obtains an OAuth 2.0 access token using client credentials, private key JWT, and DPoP flow. * The plugin automatically injects Authorization and related headers. * The API returns a successful response for authorized scope.