我曾经遇到过使用Flutter在PayPal中获取访问令牌的问题
我该如何解决这个问题?
答案 0 :(得分:0)
尝试此功能。希望它能工作。
Future makePost() async {
String username = "*************";
String password = "*************";
var bytes = utf8.encode("$username:$password");
var credentials = base64.encode(bytes);
Map token = {
'grant_type': 'client_credentials'
};
var headers = {
"Accept": "application/json",
'Accept-Language': 'en_US',
"Authorization": "Basic $credentials"
};
var url = "https://api.sandbox.paypal.com/v1/oauth2/token";
var requestBody = token;
http.Response response = await http.post(url, body: requestBody, headers: headers);
var responseJson = json.decode(response.body);
return responseJson;
}