-
Notifications
You must be signed in to change notification settings - Fork 75
Deploy full scale oauth functionality #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a98fb2c
3328bd1
e0d9f15
e910186
9cc7e6c
5ae3910
81c5628
25b1849
1c64c5d
ecd30c6
5e292b5
e5b000c
c45c24f
2b5a2a1
e55bc32
b41c60f
145033e
5111e66
049a4c3
b66a9ab
78eadcf
435777a
ba364d9
078d2ce
61dd172
211dbd3
33bd9e1
89022d1
39e96e9
94294ce
d78e866
58361bc
fdffa30
2d31163
192aad7
8b88396
aab631f
eb7d5b6
939bb70
4ff27ab
d5e19d6
773efbc
61fc9cc
1fbac91
d9c5e34
59389b0
deb7dc7
b2b8757
a40be92
7f76f59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,61 @@ | ||
const Ebay = require('../src/index'); | ||
const { clientId, clientSecret } = require('./credentials/index'); | ||
|
||
let access_token = ''; | ||
let ebay = new Ebay({ | ||
clientID: clientId, | ||
clientSecret: clientSecret, | ||
body: { | ||
grant_type: 'client_credentials', | ||
scope: 'https://api.ebay.com/oauth/api_scope' | ||
|
||
} | ||
}); | ||
|
||
// Getting access token and calling getItem method. | ||
ebay.getAccessToken() | ||
ebay.getApplicationToken() | ||
.then((data) => { | ||
ebay.getItem('v1|202117468662|0').then((data) => { | ||
ebay.setAppAccessToken(data); | ||
ebay.getItemById('v1|202117468662|0').then((data) => { | ||
console.log(data); | ||
// Data is in format of JSON | ||
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0) | ||
}) | ||
}); | ||
|
||
|
||
// Reference ebay developer page https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemByLegacyId#_samples | ||
// Getting access token and calling getItemByLegacyId method. | ||
ebay.getAccessToken() | ||
ebay.getApplicationToken() | ||
.then((data) => { | ||
ebay.setAppAccessToken(data); | ||
ebay.getItemByLegacyId({ | ||
'legacyItemId': 2628001 // Get Item Details Using a Legacy ID | ||
legacyItemID: 2628001 // Get Item Details Using a Legacy ID | ||
}).then((data) => { | ||
if (!data) console.log(data); | ||
console.log(data); | ||
// Data is in format of JSON | ||
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0) | ||
}); | ||
}); | ||
|
||
//Get Item Details Using a Legacy ID and SKU | ||
ebay.getAccessToken() | ||
// Get Item Details Using a Legacy ID and SKU | ||
ebay.getApplicationToken() | ||
.then((data) => { | ||
ebay.setAppAccessToken(data); | ||
ebay.getItemByLegacyId({ | ||
'legacyItemId': 2628001, | ||
'legacyVariationSku': 'V-00031-WHM' | ||
legacyItemID: 110039490209, | ||
legacyVariationSku: 'V-00031-WHM' | ||
}).then((data) => { | ||
if (!data) console.log(data); | ||
console.log(data); | ||
// Data is in format of JSON | ||
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0) | ||
}); | ||
}); | ||
|
||
|
||
//retrieves the details of the individual items in an item group | ||
// retrieves the details of the individual items in an item group | ||
// reference https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemsByItemGroup#uri.item_group_id | ||
ebay.getAccessToken() | ||
ebay.getApplicationToken() | ||
.then((data) => { | ||
ebay.getItemByItemGroup('151915076499').then((data) => { | ||
ebay.setAppAccessToken(data); | ||
ebay.getItemByItemGroup('351825690866').then((data) => { | ||
// Data is in format of JSON | ||
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0) | ||
console.log(data) | ||
}, (error) => { | ||
console.log(error); | ||
}); | ||
}); | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ ebay.findItemsByKeywords({ | |
Condition: 3000, | ||
SoldItemsOnly: false, | ||
affiliate: { | ||
networkId: 9, | ||
trackingId: 1234567890 | ||
networkID: 9, | ||
trackingID: 1234567890 | ||
} | ||
}).then((data) => { | ||
console.log(data); | ||
|
@@ -36,7 +36,7 @@ sale by category (using categoryId), by keywords (using keywords), or a combinat | |
Keyword queries search the title and subtitle of the item; they do not search descriptions. */ | ||
ebay.findCompletedItems({ | ||
keywords: 'Garmin nuvi 1300 Automotive GPS Receiver', | ||
categoryId: '156955', | ||
categoryID: '156955', | ||
sortOrder: 'PricePlusShippingLowest', //https://developer.ebay.com/devzone/finding/callref/extra/fndcmpltditms.rqst.srtordr.html | ||
Condition: 3000, | ||
SoldItemsOnly: true, | ||
|
@@ -50,7 +50,7 @@ ebay.findCompletedItems({ | |
// // This call searches for items on eBay using specific eBay product values. | ||
// https://developer.ebay.com/DevZone/finding/CallRef/findItemsByProduct.html#findItemsByProduct | ||
ebay.findItemsByProduct({ | ||
productId: 53039031, | ||
productID: 53039031, | ||
entriesPerPage: 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TotallyNotChase I don't think you have to change variable names as part of this PR, since this library is out and many people are using it. It would be difficult until or unless we have mention these changes as breaking changes and release a major version. |
||
}).then((data) => { | ||
console.log(data); | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const Ebay = require('../src/index'); | ||
const { clientId, clientSecret } = require('./credentials/index'); | ||
|
||
let ebay = new Ebay({ | ||
clientID: clientId, | ||
clientSecret: clientSecret, | ||
}); | ||
|
||
ebay.getApplicationToken() | ||
.then((data) => { | ||
console.log(data); | ||
if (!data.error) { | ||
ebay.setAppAccessToken(data); | ||
console.log(`App token: ${ebay.appAccessToken}`); | ||
} | ||
}); | ||
|
||
setTimeout(() => { | ||
ebay.getApplicationToken() | ||
.then((data) => { | ||
console.log(data); | ||
if (!data.error) { | ||
ebay.setAppAccessToken(data); | ||
console.log(`App token: ${ebay.appAccessToken}`); | ||
} | ||
}); | ||
}, 7200); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const readline = require('readline'); | ||
const Ebay = require('../src/index'); | ||
const { clientId, clientSecret, redirectUri } = require('./credentials/index'); | ||
|
||
let ebay = new Ebay({ | ||
clientID: clientId, | ||
clientSecret: clientSecret, | ||
redirectUri: redirectUri, | ||
}); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
|
||
const authURL = ebay.getUserAuthorizationUrl(); | ||
console.log(`Please go here for auth code: ${authURL}`); | ||
rl.question("Enter the auth code recieved from the redirect url: ", code => { | ||
rl.close(); | ||
ebay.getAccessTokenByCode(code).then(data => { | ||
console.log(data); | ||
if (!data.error) { | ||
ebay.setUserAccessToken(data); | ||
console.log(`User token: ${ebay.userAccessToken}\nRefresh token: ${ebay.refreshToken}`); | ||
} | ||
}) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we keep name as
getAccessToken
since we are using this convention from the start ?.