question

dotor3382 avatar image
0 Likes"
dotor3382 asked

How to integrate "Sign in with Ebay" (OAuth) in React.js?

I was able to authenticate a user by going manually in the browser to:

https://auth.sandbox.ebay.com/oauth2/authorize?client_id=${ebayClientId}&redirect_uri=${redirectURIName}&response_type=code


And in my web server I defined a callback like so:

@Get('/auth/ebay/callback')
public authCallback(@Req() req: Request) {
const redirectURIName = this.configService.get(ConfigKeys.ebayRuName)
const ebayClientId = this.configService.get(ConfigKeys.ebayAppId)
const ebaySecretId = this.configService.get(ConfigKeys.ebayCertId)
axios('https://api.sandbox.ebay.com/identity/v1/oauth2/token', {
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization:
        'Basic ' +
        btoa(`${ebayClientId}:${ebaySecretId}`)
},
data: 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: redirectURIName
})
})
.then(response => console.log(response))
.catch(err => console.log(err))
}


But now I try to do this flow in my React app. How can I add a button that will redirect to ebay sign in screen?

I searched for the API docs, the web for this topic, even examples, but with no luck.


For example authentication with google/facebook is done using a library that opens an iframe and returns the user_id once the user signed in. All without backend included. later with that user_id I can authenticate the user in the backend.


How can I achieve something like this with Ebay OAuth?

oauth2javascriptsign inreact
· 3
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

oauth is a very general concept and a ebay specific thing, you probably will find more answers in any react forum than here, because it's not an ebay question, it's a programming language one.
0 Likes 0 ·

I just don't get how other websites integrate sign in with ebay in their client side. There are no resources for this at all

0 Likes 0 ·

the url for your button can be found here. and u get a lot of info here as well.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.