question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XsuaaTokenFlows: Deprecated constructors for client credential based authentication

See original GitHub issue

Hello Colleagues, could you please provide an example for the proper usage of Example Usage of XsuaaServiceConfiguration?

The background of this request is the following: We have developed a service which in turn is calling an instance of the Market Rates Management (MRM) service. For the MRM call we first get the access token from the uaa instance bound to the MRM service. Currently we use the following coding for this purpose:

XsuaaTokenFlows tokenFlows =
        new XsuaaTokenFlows(
            new DefaultOAuth2TokenService(),
            new XsuaaDefaultEndpoints(uaaUrl),
            new ClientCredentials(clientId, clientSecret));

return tokenFlows.clientCredentialsTokenFlow().execute().getAccessToken();

In this solution uaaUrl, clientId and clientSecret are coming from uaa environment variables (VCAP_SERVICES):

@Value("${vcap.services.bpi-market-rates.credentials.uaa.url}")
String uaaUrl;

The solution was/is working as expected but unfortunately the used constructor version of XsuaaTokenFlows is now deprecated. For the alternative constructor we need an instance of OAuth2ServiceConfigurationProperties. I have seen that XsuaaServiceConfiguration is a specialization of OAuth2ServiceConfigurationProperties. My question now is, how do we get a proper instance of XsuaaServiceConfiguration?

Seeing that the SpringBoot annotation @ConfigurationProperties(“sap.security.services.xsuaa”) is used I’m wondering from where the properties are really taken from and how can I get an instance which then contains the uaa-credentials of the MRM service and not the ones of my own service?

And maybe one additional remark: at the end my own service should be called from the BTP Job Scheduler - I’m not sure if this adds additional complexity for getting the MRM credentials.

Thanks in advance for your help!

Best regards, Sven.

P.S.: If have seen that there was already a similar question raised but this doesn’t answer my question above.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nenaraabcommented, Nov 15, 2021

Hi @shravanpishike thanks for the additional remark…

Finally, instead of

XsuaaTokenFlows tokenFlows =
        new XsuaaTokenFlows(
            new DefaultOAuth2TokenService(),
            new XsuaaDefaultEndpoints(uaaUrl),
            new ClientCredentials(clientId, clientSecret));

…instantiate XsuaaTokenFlows like that:

ClientIdentity identity = new ClientCredentials(clientId, clientSecret);

XsuaaTokenFlows tokenFlows =
        new XsuaaTokenFlows(
            new DefaultOAuth2TokenService(HttpClientFactory.create(identity)),  
            new XsuaaDefaultEndpoints(uaaUrl, null), // available as of 2.11.3
            identity
           );
Read more comments on GitHub >

github_iconTop Results From Across the Web

XsuaaService (SAP Cloud SDK - Parent POM 3.15.1 API)
Retrieves an AccessToken for a given pair of client credentials in the name of an authenticated user (to be found in the JWT...
Read more >
How to Use Client Credentials Flow with Spring Security
RestTemplate is deprecated, and while still widely used, should probably not be used for new code. Instead, the WebFlux-based class, WebClient ...
Read more >
DefaultPasswordTokenRespons...
Deprecated. The latest OAuth 2.0 Security Best Current Practice disallows the use of the Resource Owner Password Credentials grant. See reference OAuth 2.0 ......
Read more >
Is it disallowed or only discouraged to use Resource Owner ...
The Resource Owner Password Credentials (ROPC) flow is deprecated - basically from the start - because it defeats one of the primary ...
Read more >
GoogleCredential (google-api-client 1.33.2) - javadoc.io
Please use google-auth-library for handling Application Default Credentials and other non-OAuth2 based authentication. @Deprecated public class GoogleCredential ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found