[英]Adding extra auth parameter to client credentials grant type in Ballerina?
I need to send a request like the one below.我需要发送如下请求。
curl --request POST --url https://dev-jlsubxnitkpok2tw.au.auth0.com/oauth/token
--header 'content-type: application/json' \
--data '{"client_id":"","client_secret":"","audience":"","grant_type":"client_credentials"}'
I am using Ballerina like below我正在使用像下面这样的 Ballerina
http:Client securedEP = check new ("http://postman-echo.com", {
auth: {
tokenUrl: "xxx/oauth/token",
clientId: "xxx",
clientSecret: "xxx",
scopes: ["read", "submit"]
}
}
I get an error like the one below from the service.我从服务中收到如下所示的错误。
cause: Failed to get a success response from the endpoint. Response code: '403'.
Response body: '{"error":"access_denied","error_description":"No audience
parameter was provided, and no default audience has been configured"}'
How can I achieve this in Ballerina?我怎样才能在 Ballerina 中做到这一点?
You can use the optionalParams
parameter in ClientCredentialsGrantConfig to specify that.您可以使用ClientCredentialsGrantConfig中的
optionalParams
参数来指定它。
http:Client securedEP = check new ("http://postman-echo.com", {
auth: {
tokenUrl: "xxx/oauth/token",
clientId: "xxx",
clientSecret: "xxx",
scopes: ["read", "submit"],
optionalParams: {
"audience": "aud"
}
}
});
Note that the auth
record field here is coming from CommonClientConfiguration type.请注意,此处的
auth
记录字段来自CommonClientConfiguration类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.