I am trying to create a flutter application using woocomerce API.
for that woocommerce i have created in my localhost
import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:ecommerce_store/config.dart';
import 'package:ecommerce_store/models/customer.dart';
class APIService {
Future<bool> createCustomer(CustomerModel model) async {
var authToken = base64.encode(
utf8.encode(Config.key + ":" + Config.sceret),
);
bool ret = false;
try {
var response = await Dio().post(
Config.url + Config.customerURL,
data: model.toJson(),
options: Options(headers: {
HttpHeaders.authorizationHeader: 'Basic $authToken',
HttpHeaders.contentTypeHeader: 'application/json'
}),
);
if (response.statusCode == 201) {
ret = true;
}
} on DioError catch (e) {
if (e.response?.statusCode == 401) {
ret = false;
} else {
ret = false;
}
// print(e);
}
return ret;
}
}
but when I try to do post-operation am getting
{
"code": "woocommerce_rest_cannot_view",
"message": "Sorry, you cannot list resources.",
"data": {
"status": 401
}
}
I saw that to access localhost API we need to use oauth1 but can anyone help me how to convert basic auth to oauth1
Thank you very much in advance