cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to consume APIs from API Management from API Hub - 401 unauthorized (OAuth 2.0)

jonas_kinold
Explorer
0 Kudos

Hello Community,

I would like to consume the APIs from the API Business Hub from the API Management (e.g. https://api.sap.com/api/APIPortal_CF/resource). Unfortunately it is not possible for me to call them correctly and without errors.

The only authentication option offered for the APIs in the API Business Hub is OAuth2.0 credentials.

To get the credentials I created an instance in the BTP cockpit (Cloud Foundry) for the Authentication and Trust Management Service, with the plan "apiaccess".
For this instance I have now created the service key, which contains the clientid/secret and the token URL.
I use these credentials to generate the access token and send it as authentication bearer header to the endpoint of the API.
Thereupon I get a HTTP 401 unauthorized without any further error message.

Is this the right way to get the OAuth2.0 credentials to call the API from the API Business Hub?

What mistakes have I possibly made or what have I possibly overlooked in this scenario?


With kind regards

Jonas

View Entire Topic
lucasvaccaro
Product and Topic Expert
Product and Topic Expert

Hi Jonas,

In general, you need to create a service key of the respective service that you're going to consume.

A service key of the Authentication and Trust Management Service is used to consume the XSUAA APIs (e.g. user management).

To consume the APIs provided by the API Management Service, you'll need to create a service instance and service key of the API mgmt service. For more details, see this help page.

Best regards,
Lucas

jonas_kinold
Explorer

Hi Lucas,

thank you for your answer. Indeed that helped, but only if i use these service keys in combination with the Authentication and Trust Management Service Instance.

To consume the APIs or the API Business Hub Enterprise of the APIM it is a requirement to have an instance of the Authentication and Trust Management Service Instance before. After that everything works if i use the credentials from the APIM service Keys!

Thank you!