使用 apigee 在 OAuth2 上请求访问令牌时出错

问题描述

生成一个 jwt 令牌,现在我需要通过调用 OAuth2 来生成一个访问令牌。 因此,我创建了一个服务标注并放置了我的 jwt 令牌,但得到了错误代码 500(“无效的模拟子字段”),但我找不到出现此错误的原因。

这是我的 xml 服务标注:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout name="SC.ExchangeIdForAccesstoken">
    <Request variable="accesstokenRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
        <Set>
            <FormParams>
                <FormParam name="assertion">{jwt-variable}</FormParam>
                <FormParam name="grant_type">urn:ietf:params:oauth:grant-type:jwt-bearer</FormParam>
            </FormParams>
        </Set>
    </Request>
    <Response>access_token.response</Response>
    <HTTPTargetConnection>
        <URL>https://oauth2.googleapis.com/token</URL>
    </HTTPTargetConnection>
</ServiceCallout>

这是我的流程:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>Set-JWT-Secret</Name>
            </Step>
            <Step>
                <Name>Generate-JWT</Name>
            </Step>
            <Step>
                <Name>SC.ExchangeIdForAccesstoken</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPProxyConnection>
        <BasePath>/gm-kite-svc-proxy</BasePath>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="default">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

如果有人知道如何解决问题,那将是一个很大的帮助。

非常感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)