cancel
Showing results for 
Search instead for 
Did you mean: 

Getting oAuth2 token after Onboarding is completed

0 Kudos

Hey, basically I want to call my ODATA service, but not use the generated methods, because one of them is not behaving right. (I have opened a support incident).

As a workaround, I generated a helper class with https://app.quicktype.io/ with the ODATA json, and am querying that now.


For querying the ODATA service, obviously I will need the oauth token that was recieved during the onboarding/login process. I now need to programatically get this.

For a prototype, I just looked at what request headers the SDK's generated methods use, but of course, that can change depending on the user, so it's a terrible hack.


Tried to look at the docs, tested out things for 2 hours but it didnt work out. Tried to use some of the global variables, but they didn't contain anything helpful.

Links:

https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/2.0/en-US/Documents/Frameworks/SAPFoundati...

https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/2.0/en-US/Documents/Frameworks/SAPFoundati...

https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/2.0/en-US/Documents/Frameworks/SAPFoundati...

Accepted Solutions (0)

Answers (1)

Answers (1)

aschlosser
Employee
Employee
0 Kudos

Carsten,

The easiest would probably be to use the configured SAPURLSession (with an OAuth2 observer attached) also for connecting to the OData service directly. This way, the OAuth2 token would always be added to outgoing requests.

If this cannot be done, you could implement your own OAuth2TokenStore and configure the OAuth2Observer with it.

If you're using the Flows framework, the OnboardingContext.credentialStore will hold the token after onboarding is completed.

Not sure about your exact scenario - hope any of this is helpful...

Thanks
Andreas