从eBay获得Oauth令牌需要什么请求和响应的组合?什么是runame,为了使eBay开心我需要什么标题?
[经过三天令人沮丧的尝试让Ebay的oauth给我访问令牌后,我终于解决了。由于文档很痛苦,在线上几乎没有帮助,所以我决定将解决方案发布在这里,希望对其他人有所帮助。我不擅长StackOverflow,所以请告知是否需要改善格式。
app.get("/login/ebay", (req, res) => {
res.redirect(`https://auth.sandbox.ebay.com/oauth2/authorize?client_id=DeanSchm-TestApp-SBX-b843acc90-fd663cbb&redirect_uri=Dean_Schmid-DeanSchm-TestAp-kqmgc&response_type=code`
);
});
您要做的第一件事就是重定向到该URL。
格式是这样
https://auth.sandbox.ebay.com/oauth2/authorize?client_id=&redirect_uri=&response_type=code
也有一个scope属性,但我还不明白,所以我找回了一个没有is的令牌。
该URL会将您带到eBay登录页面。如果使用沙箱,则需要创建沙箱用户并使用沙箱凭据登录。
登录后,eBay会将您重定向到您选择的URL。您输入要重定向到的URL。
位于“通过您的应用程序从Ebay获取令牌的ebay开发人员”部分中。>
此URL可以是任何内容。您只需要在node或express或其他方式中处理它,因为一旦有人登录该URL,便会到达他们的目的地。
这是我的处理方式
app.get("/auth/ebay/callback", (req, res) => { axios("https://api.sandbox.ebay.com/identity/v1/oauth2/token", { method: "post", headers: { "Content-Type": "application/x-www-form-urlencoded", Authorization: "Basic " + btoa( `client public key:client secret keys` ) }, data: qs.stringify({ grant_type: "authorization_code", // parsed from redirect URI after returning from eBay, code: req.query.code, // this is set in your dev account, also called RuName redirect_uri: "Dean_Schmid-DeanSchm-TestAp-kqmgc" }) }) .then(response => console.log(response)) .catch(err => console.log(err)); });
一些吸引我的陷阱。