【发布时间】:2020-10-23 19:43:00
【问题描述】:
我正在使用 OAuth 1.0 调用 api,并且我正在使用以下包进行 api 调用。但我收到以下错误。请任何人指导我修复此错误。
api调用库:
我的代码:
const String apiKey = 'ck_789b63aee985c4569bfa5ae4724861ae5c74c337';
const String apiSecret = 'cs_0f0addbc9c16042d5689a4cfe6fbfd209b00d55b';
var clientCredentials = new oauth1.ClientCredentials(Uri.encodeComponent(apiKey), Uri.encodeComponent(apiSecret));
// create Authorization object with client credentials and platform definition
//var auth = new oauth1.Authorization(clientCredentials, platform);
var auth = new oauth1.Credentials(apiKey, apiSecret);
// yeah, you got token credentials
// create Client object
var client = new oauth1.Client(platform.signatureMethod, clientCredentials, auth);
// now you can access to protected resources via client
client.get('http://demo2.signitydemo.in/foodemporium/wp-json/wc/v3/products/categories').then((res) {
print("res.body===${res.body}");
print("statusCode===${res.statusCode}");
print("headers===${res.headers}");
});
{"code":"woocommerce_rest_authentication_error","message":"Invalid signature - provided signature does not match.","data":{"status":401}}
标题:
{link: <http://demo2.signitydemo.in/foodemporium/wp-json/>; rel="https://api.w.org/", access-control-allow-headers: Authorization, Content-Type, connection: keep-alive, date: Fri, 03 Jul 2020 05:32:04 GMT, transfer-encoding: chunked, vary: Origin, access-control-expose-headers: X-WP-Total, X-WP-TotalPages, x-robots-tag: noindex, content-type: application/json; charset=UTF-8, x-content-type-options: nosniff, server: nginx}
【问题讨论】:
标签: android http flutter dart oauth-1.0a