调用支持oAUTh2的API [英] Calling an oAUTh2 enabled API

查看:157
本文介绍了调用支持oAUTh2的API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我们使用Azure来调用我们的API。

We are using Azure to call our APIs.

在调用主API之前,我们需要发送令牌在标题中。我们已经为API设置了OAUTH2。

Before calling our main API we need to send a token in the header. We have set up the OAUTH2 for the API.

目前我们必须获取令牌,然后将标头中的令牌发送到从我们的API获取结果。 

At the moment we have to get the token and then send the token in the header to get results from our API. 

我们是否可以发送一个可以生成令牌并将其传递到标头中的请求并调用后续的API?

Is it possible we can send a single request which can generate the token and pass it in the header and call the subsequent API ?

祝你好运

VS_TR

推荐答案

这取决于您的使用案例。

It would depend on your use case.

如果您的目标是用户身份,然后

但是如果APIM可以自己访问后端API,那么

If you are aiming for user identity, then no.
But if you are OK with APIM acting as itself to access the back end API, then yes.

您可以简单地制定一项APIM政策(发送请求)相应地获取访问令牌(使用
客户端凭据流最有可能)并在其对后端API的请求中使用它。

You could simply have an APIM policy (send-request) that fetches the access token accordingly (using client credentials flow most likely) and use that in its request to the back end API.


这篇关于调用支持oAUTh2的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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