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

Get Token OAuth 2.0 Authorization Code SAP API

Schalager1
Participant
0 Likes
1,520

Hi,

I am developing a custom java application to call SAP API in Cloud.

Is there any example of JAVA code to get authorization token?

/oauth/authorize?response_type=code

I am able to get Bearer token from Postman app but I want to get it directly from my Java app.

I searched SAP documentation, but I didn't find a complete example.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Muniyappan
Active Contributor
0 Likes

Hi Andre,

first check if you can use the out of box solution

Fetch Oauth Token in REST is now Out of The Box | SAP Blogs

else

is this what you are looking for? You can do the look up either from java map or from udf. Store the token in dynamic configuration and use it in the channel.

Yes Rest LookUp is possible in PI | SAP Blogs

REST Look Up using UDF in SAP PO | SAP Blogs

Schalager1
Participant
0 Likes

Hi Muniyappan,

I am not using SAP PI. I am using Ecplise to develop a java console application that call rest web services of SAP API business hub.

I have uaa.url, client id and client secret. What i am triying is get oauth2 token to call web service thru java code.

Muniyappan
Active Contributor
0 Likes

is this what you are looking for?

Full Example Implementation

Schalager1
Participant
0 Likes

This example works but it's for version 1.0 of OAUTH.

I need OAuth 2.0 (there are more steps).

Muniyappan
Active Contributor

may be you can take look at this code base.

https://github.com/SAP/cloud-security-xsuaa-integration