简体   繁体   中英

Jhipster UAA External Client

I use jhipster UAA and Gatewy App in my server running in EC2. ( https://www.jhipster.tech/images/microservices_architecture_detail.002.png )

I have application running external cloud to put data in this server, It use REST endpoint to make request.

I need turn on security in this endpoint, then use access token or client secret.

I turned on the security, and copy my secret token by FrontEnd application. My first request work, but the second request don't work.

My OAuth2RestTemplate.

 @Bean
  public OAuth2RestTemplate redditRestTemplate(OAuth2ProtectedResourceDetails resourceDetails, OAuth2ClientContext clientContext) {
    clientContext.setAccessToken(new DefaultOAuth2AccessToken(applicationProperties.getAccessToken()));
    OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails, clientContext);
    AccessTokenProvider accessTokenProvider = new AccessTokenProviderChain(
      Arrays.<AccessTokenProvider>asList(
        new ImplicitAccessTokenProvider(),
        new ResourceOwnerPasswordAccessTokenProvider(),
        new ClientCredentialsAccessTokenProvider())
    );
    template.setAccessTokenProvider(accessTokenProvider);
    return template;
  }

My request.

OAuth2RestTemplate b = a.getBean(OAuth2RestTemplate.class);
String c = b.getForEntity("https://cloud.com/api/app/v1/events", String.class).getBody();

First request Ok. I need save the new accessToken?

Is there any way to do this integration using "client secret" or anything?

After making the authentication request /auth/login you have to save the accessToken received in the response. Subsequent requests must contain this access token in the header Authorization: Bearer <accessToken>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM