eBay对接流程
我看到有很多人有疑问,我留下我的联系方式,方便回答你们的问题:
有问题可以联系企鹅:805460597
有问题可以联系企鹅:805460597
有问题可以联系企鹅:805460597
文末有demo使用教程!!!
文末有demo使用教程!!!
文末有demo使用教程!!!
首先,你必须要有个eBay的开发者账号,然后使用开发者账号的信息去跳转到eBay的授权页面,拿到授权code,之后,你就可以随意控制卖家的所有操作了。
下面详细的说下操作流程:
第一步:
第二步:
点击上图的”User Tokens“,
第三步:
点击上图中的Get a Token from eBay via Your Application,然后填写上你的https的回调地址;如图
第四步:
以上准备设置完之后,就开始进入对接阶段了。
首先,你得弄明白这张图:
这个图表达的意思是:先从应用端请求eBay授权服务,跳转到eBay授权页面,由卖家登录后得到授权码(Authorization code),再使用这个授权码去请求eBay的接口获取token,最后,用这个token去调用eBay的api接口;
具体流程参考官网文档:https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html
第一步:获取eBay授权页面的地址
@GetMapping("getAuthUrl")
public Mono<String> getAuthUrl() {
OAuth2Api oauth2Api = new OAuth2Api();
List<String> scopeList = new ArrayList<>();
scopeList.add("https://api.ebay.com/oauth/api_scope");
scopeList.add("https://api.ebay.com/oauth/api_scope/sell.fulfillment");
scopeList.add("https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly");
String authorization_url = oauth2Api.generateUserAuthorizationUrl(EBayEnvironment.PRODUCTION, scopeList, Optional.empty());
return Mono.just(authorization_url);
}
第二步:根据授权url地址响应的code,去eBay获取token
@GetMapping("getToken/{code}")
public Mono<OAuthResponse> getToken(@PathVariable("code") final String code) throws IOException {
OAuth2Api oauth2Api = new OAuth2Api();
OAuthResponse oauth2Response = oauth2Api.exchangeCodeForAccessToken(EBayEnvironment.PRODUCTION, code);
return Mono.just(oauth2Response);
}
第三步:根据token获取订单数据
@GetMapping("getOrders/{token}")
public Mono<Response> getOrders(@PathVariable("token") final String token) throws IOException {
final OkHttpClient okHttpClient = new OkHttpClient();
final Request request = new Request.Builder()
.url("https://api.ebay.com/sell/fulfillment/v1/order")
.get()
.addHeader("Authorization", "Bearer " + token)
.build();
final Response response = okHttpClient.newCall(request).execute();
return Mono.just(response);
}
**
重要的事要多说几遍:
**
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
如果实在不知道怎么使用,可以看看下面这个:
手把手教你如何正确使用ebay-demo(奶爸级别教程)
手把手教你如何正确使用ebay-demo(奶爸级别教程)
手把手教你如何正确使用ebay-demo(奶爸级别教程)