在Java中使用令牌依次调用多个API [英] Calling multiple API in sequence with token in java

查看:158
本文介绍了在Java中使用令牌依次调用多个API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

生成令牌后,我必须依次调用5 APIs.我正在使用API下面的内容来生成token.

I have to call 5 APIs in sequence after generating the token. i am using below API to generate token.

POST https://idcs-xxxx.identity.c9dev2.oc9qadev.com/oauth2/v1/token

我将发送usernamepassword以获得上述API中的令牌.一旦收到令牌,我将不得不使用same token依次调用低于5 APIs的代码. 我将使用一个API中的output并将其过滤并选择一些值作为下一个API的输入.所有rest endpoint都会根据前一个API responseinput值进行更改.

I will send username and password to get token in above API. Once token will be received I will have to use the same token to call below 5 APIs in sequence. I will use output of one API and filter it and pick some values as an input to next API. all the rest endpoint will change based on the input value of previous API response.

GET https://idcs-xxxx.identity-t0.data.digitalassistant.oci.oc-test.com/api/v1/skills

GET https://idcs-oda-9417f93560b94eb8a2e2a4c9aac9a3ff-t0.data.digitalassistant.oci.oc-test.com/api/v1/skills/dynamicEntities

POST https://idcs-xxxx.identity-t0.data.digitalassistant.oci.oc-test.com/api/v1/bots/xxx/v2/yyy

PATCH https://idcs-xxxx.identity-t0.data.digitalassistant.oci.oc-test.com/api/v1/bots/xxx

PUT https://idcs-xxxx.identity-t0.data.digitalassistant.oci.oc-test.com/api/v1/bots/xxx/DONE

我如何automate token generation,并且每个API call中都可以使用相同的token. token将每隔一小时过期一次.我唯一的目的是以某种方式使上述过程自动化. 即使是最小的帮助也将受到高度赞赏.您甚至可以提出解决方案的一部分,即使不是全部.我无法从Google那里获得很多资料.

How can I automate token generation and the same token can be used in every API call. token will expire in every one hour. My only purpose is to automate above process somehow. even smallest help would be highly appreciated. you can suggest even some part of solution if not all. I could not get much material from google.

我对架构感兴趣,而不是编码.

Rather than coding I am interested in architecture.

推荐答案

Spring Security将在这里为您提供帮助.

Spring Security will help you here.

https://spring.io/blog/2018/03/06/using-spring-security-5-to-integrate-with-oauth-2-secured-services -such-as-facebook-and-github

这篇关于在Java中使用令牌依次调用多个API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆