I am trying to use the Adobe Target Admin API and I have encountered the following error while using any of the admin API request:
"message": "Api Key is invalid"
Note: The API key that I am using in any admin API request is same as the API key I used to generate JWT and access token using JWT.
Step 1: Integration of Target API with public certificate in Adobe I/O console - Successful
Step 2: Generate JWT signed with private key - Successful
Step 3: Exchange JWT with access token - Successful
Step 4: Use the access token generated in Step-3 in an admin API request - Unsuccessful (Error Message - "Api key is Invalid")
Is it because of the fourth parameter in JWT payload from API Integration is different from that provided in sample code of Adobe I/O Authentication document? i.e.
Parameter in Sample code: 'https://ims-na1.adobelogin.com/s/ent_smartcontent_sdk': true
Parameter in JWT payload from API: "https://ims-na1.adobelogin.com/s/example_sdk": true,
Here's a more detailed step by step how to document on generating the API token. Please try these steps to check if your issue is resolved .
1 - Generate private key and public certificate per the following documentation: https://www.adobe.io/apis/cloudplatform/console/authentication/createcert.html
On a Mac, the following commands are built into terminal.
On a PC, you will need to download Cygwin (or other tool of personal preference) and run it from command line. Here are the steps to download and install Cygwin:
Notes: Your home directory will be: C:\cygwin64\home\WINDOWSUSER
You can search for and install additional packages during the install phase. I recommend installing everything related to "curl" and "ssh"
Here is the command to run:
$ openssl req -nodes -text -x509 -newkey rsa:2048 -keyout secret.pem -out certificate.pem -days 356
Note: It will ask you several questions that you need to fill out to generate the certificate, see screenshot below:After the files have been created, you will convert the secret.key to secret.pem using the following command:
$ openssl pkcs8 -topk8 -inform PEM -outform DER -in secret.pem -nocrypt > secret.key
Here are the files that are created on your file system (you may move these files to another location on your machine at this point for organization):Notes: The files will be generated in your home directory: C:\cygwin64\home\WINDOWSUSER
2 - Create integration within the Adobe IO console:
click "New Integration" button
Select "Access an API" option, then click "continue"
Select Adobe Solution (currently only available for Target)
Note: User must be a user of the Experience Cloud AND have access to that solution.Select "New integration" and click "Continue"Fill out integration formDrag "certificate.pem" from file system into form to uploadOnce the file is uploaded, click "Create integration" button - see screenshot: fileuploaded_createintWhen processing is complete, click "continue to integration details"Success! You have now created an integration
3 - Generate JSON Web Token (JWT):
In the Integration UI, click on the JWT tab, paste in private key, click Generate JWT button - see screenshot: generating JWT - inputOnce it is generated, you will see the JWT and a sample CURL command
Click on "copy" icon below "Generated JWT"4 - Exchange JWT for Bearer Access Token:
Note: If you run this in terminal on a Mac, the response seems to get truncated. Instead, use Postman
Download and install free API tool named "Postman" (available on Mac, Windows, or Linux): https://www.getpostman.com/
Import this api call into Postman by copying the code below into a text file on your computer with a .json extension:
example filename: exchangeJwt.json
Import file into Postman by going to file > Import: you can drag and drop the .json file here or browse for the fileThis will create a "collection" in Postman on the left-hand side, with one API call in it named "Exchange JWT for Bearer token"Click on the API call "Exchange JWT for Bearer token"
In the main section of the UI this is what you will seeNote: as highlighted in red above, I'm in the "Body" tab. If you are in another tab, you will not see the three pieces of information that are required
The bearer token is retrieved, which will be used to make API calls
The access_token is what will be used as part of the API calls you intend to run
5 - Example API call:
Run Target call with access token
Hi There, Thanks for the reply. The error that I am facing is on the 5th step (in the flow mentioned). I have successfully completed first four steps and have successfully generated an Access Token with (X) client secret and (Y) client ID (or API ID). When I am using the access token generated to access an API (i.e. step 5) I am getting an error of "API Key is invalid", I am using the same API Key (Client ID) that i used to generate Access token.