1. 获取access_token
官方链接
1.1 请求路径 POST
地区 |
URL |
NA |
https://api.amazon.com/auth/o2/token |
EU |
https://api.amazon.co.uk/auth/o2/token |
FE |
https://api.amazon.co.jp/auth/o2/token |
1.2 请求事例
curl \ -X POST \ -H "Content-Type:application/x-www-form-urlencoded;charset=UTF-8" \ --data "grant_type=refresh_token&client_id=YOUR_CLIENT_ID&refresh_token=YOUR_REFRESH_TOKEN&client_secret=YOUR_CLIENT_SECRET" \ https://api.amazon.com/auth/o2/token
1.3 代码实操
HashMap<String, Object> map = new HashMap<>();
map.put("grant_type","refresh_token"); map.put("refresh_token","your refresh_token");
map.put("client_id","your client_id");
map.put("client_secret","your client_secret");
String getAccessUrl = "https://api.amazon.com/auth/o2/token";
String result = HttpUtil.doPost(getAccessUrl,map,null);
Map map1 = JSONObject.parseObject(result, Map.class);
String access_token = (String) map1.get("access_token");
System.out.println("access_token = " + access_token);
运行结果如下:
2. 获取profileId
官方连接
2.1 请求路径 GET
https://advertising-api.amazon.com/v2/profiles
2.2 请求参数
参数名称 |
可能的值(string) |
apiProgram |
billing, campaign, paymentMethod, store, report, account, posts |
accessLevel |
edit, view |
profileTypeFilter |
seller, vendor, agency |
validPaymentMethodFilter |
true, false |
请求头:
key |
value |
Content-Type |
application/json |
Authorization |
access_token |
Amazon-Advertising-API-ClientId |
your client_id |
2.3 代码实操
String url = "https://advertising-api.amazon.com/v2/profiles?apiProgram=billing&profileTypeFilter=seller&validPaymentMethodFilter=true";
HashMap<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type"