When using Oauth2.0, one of the errors observed is:
{“fault”:{“faultstring”:“Invalid API call as no apiproduct match found”,“detail”:{“errorcode”:“keymanagement.service.InvalidAPICallAsNoApiProductMatchFound”}}}
I would like to explain here a few possible causes for this error with the help of an example.
Example
Let’s say we have the Environment, API Proxies, Products, Developer Apps and Developer setup in an org “sample” as shown below:
Environments
test
prod
API Proxies
API_One deployed in prod and test environments
API_Two deployed in prod and test environments
Products
Product_One associated with API_One. Product_One is enabled for test environment only.
Product_Two associated with API_Two. Product_Two is enabled for prod environment only.
DeveloperApps
App_One associated with Product_One
App_Two associated with Product_Two
Developers
Dev_One associated with App_One
Dev_Two associated with App_Two
With this setup, we can get the “Invalid API call as no apiproduct match found” error with the following scenarios listed below:
Scenario 1
- Generate the access token by using the Client_ID/Client_Secret from “App_Two”
- Run the API call for “API_One” with the above generated access token
In this scenario, we are using the access token generated for App_Two that is linked with Product_Two /API_Two to run the API call for API_One. This is a clear mismatch.
Scenario 2
- Generate the access token by using the Client_ID/Client_Secret from “App_One”
- Run the API call for “API_One” with the above generated access token for prod environment
In this scenario, we are using the access token generated for App_One in prod environment. However, the App_One is associated with Product_One, which is enabled only for test environment for the APIProxy “API_One”. This is a clear mismatch.
In summary, here are a few possible causes for the error “Invalid API call as no apiproduct match found" when using OAuth2.0
- Access token generated with Client_ID/Client_Secret from a DeveloperApp-Product unrelated to an API Proxy
- Access token generated with Client_ID/Client_Secret from a Product-DeveloperApp unrelated to environment in which the API call is tested
Solution
To avoid the error“Invalid API call as no apiproduct match found", we need to
- Generate the access token using the Client_ID/Client_Secret from the DeveloperApp-Product associated with a specific API Proxy
- Use the generated access token to run the API call for the specific API Proxy in the specific environment (s) in which the Product is enabled.
In the example quoted above, we should do the following to avoid the error“Invalid API call as no apiproduct match found"
- Generate the access token using the Client_ID/Client_Secret from the DeveloperApp “App_One”.
- App_One is associated with Product_One (enabled in test environment), which is further associated with API_One proxy.
- Run the API call with the generated access for API_One proxy only in test environment.