cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get token in SAP Foundry for API api.cf.eu10.hana.ondemand.com

enric101
Active Contributor
0 Likes
2,188

Hi gurus,

I'm trying to get Bearer token from cloud foundry API in order to get information related with deploys ( like CF client with command mta-ops).

Unfortunally, I can't get the authorization.

Could you give some information about the authorization for this API? And if anybody have and example it would be fantastic!

Thanks in advance

Regards

Enric

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
SAP Mentor
SAP Mentor

My pull request: cloud-cap-multitenancy/pull/1/files contains an example working in REST client.

enric101
Active Contributor

Thanks Gregor! As always, your post and answers are an inspiration!

I has checked your example with postman and works fine 🙂

ravindrapawar
Participant

Hi Gregor.

I am trying to get the bearer token with the authorization endpoint POST https://login.cf.eu20.hana.ondemand.com/oauth/token?grant_type=password and passed CF username and password(same user used for cf login) in the body but it gives invalid_client error. With the access token I want to access the CF API /v3/audit_events to get the deployed app's audit events. When I pass the token returned by CF command cf oauth-token I am able to get the audit events. Looking to get the same token with REST client.

In the git example the authorization header has been passed with some static value which is confusing. 

'Authorization': 'Basic Y2Y6'
Could you please advise with the right authorization header and user to be used to fetch the bearer token?
 
Thanks, Ravindra

Answers (2)

Answers (2)

CarlosRoggan
Product and Topic Expert
Product and Topic Expert

Hi,
I'm not familiar with it, just in case it helps:
are you using your platform user and are you using
cf oauth-token
to get the jwt ?
Cheers,
Carlos

enric101
Active Contributor
0 Likes
Thanks Carlos!I didn't know this CF command, but thank you very much because it has been great for me to validate the solution. As always, learning new things thanks to your contributions.
ennoury
Participant
0 Likes

Hi Enric,

For access token signing and verification across your configuration, ensure that the JWT settings are exactly the same for every web node. These JWT settings are defined on each web node in the configuration file, appsetting.json. As defined by HTTP/1.1 [RFC2617], the application should send the access_token directly in the Authorization request header. You can do so by including the bearer token's access_token value in the HTTP request body as 'Authorization: Bearer {access_token_value}'. When the API call is sent with the token, Machine Learning Server attempts to validate that the user is successfully authenticated and that the token itself is not expired. If an authenticated user has a bearer token's access_token or refresh_token that is expired, then a '401 - Unauthorized (invalid or expired refresh token)' error is returned. If the user is not successfully authenticated, a '401 - Unauthorized (invalid credentials)' error is returned.

Cheers,