Transcript for:
Understanding eBay API and OAuth Process

hi everyone so if we want to use eBay API the first thing we would require is we need oauth token from eBay and in this process we require two two tokas one is called application token and one score user access tokens so let's see each of them one by one and that's first photo eBay Developers so I have already logged into eBay this is my developer page let me first show you these three uh things one is called application key set you can see it in the very top right side as you can see my mouse pointer first thing is application which key set second is user access token third is alert is notifications so these three things let me show you one by one first reps go to application key sets so this is my application Keys page I have two sets of application Creations one is sandbox involvement one is spot production environment so for install connections I have found that the sandbox credential of may not work properly in some of the apis and in recently I.E was facing challenge with my sandbox user resident so I will print I'm going to use only the abruption potentials for this video and this is the name of my application that I have given to it and these three sets of software ensure that I have received one is called app ID or client ID second is Dev ID and third one is the set audio Appliance Secret so we need to remember uh these names I mean this scholar State like app ID because we are going to use them in our application so we have this what this pops as well and the bottle and we will come to them uh later so after application cases we have user access tokens for let's both of this stage and this is my user token page this is the name of my application and this is the environment I have chosen these here you can find your app ideal client ID so relax go to get a token from eBay by your application so currently the thing that you have no redirect URLs click here to add one so this is sticking take care so this is how a redirect to other page will look like audio name which is eBay and what is the ru name whatever is written here in my case it is and it will be required by then the user Bill signing like for creating a signing page we will require uh redirect URL name as a query parameter so this name correct is actually not correct this audio name is not correct I have changed very many credential security purpose so here it is a signing page for athenaut and you can see that our your name is mentioned here and oauth signing page we can see the J directory button is mentioned here okay so what is the difference between Authority and oath so when we are developing a application for a single user for example if you are developing an application for seller who want to list their list products on eBay with the help of API then we use author not signing and for traditional apis uh also the or cannot sign movies used but in you will perform mostly org mode of sign in which is this URL foreign then this is a display title if you see the right part here it is a preview page up over consent user consent page so we can see the display Title Here like we have this variable so if I imaginary name here let's say I imagine r2day2 then R22 is mentioned in every hour wherever the display tattoo this was mentioned hurricane then we have privacy URL they can keep it planned for now then we have auth accepted URL and the north decline the URL and we need to keep in mind that all the URL must be which means that they all should be https only okay so we can keep this CRS blank Corner because if I zoom a bit once again it is saying that if you leave these squares playing the eBay default accept and reject pages will be used so what are the default accept page this is the default accept page saying thank you authorization successfully completed you can save the browser the reject pin will be this kind of cable authorization can set you can post the window the kitchen so you will leave this feels blank then we have about this pages with okay but we can keep it blank for more so but I think this part is also covered next is alert and notification to make important so this is notification page there's not too much anything in this space all I want to show is the setting that I have made after which I bought the production candies so this is a competition and then I selected Exempted from a Marketplace accommodation and the reason for exemption is DB data so when I made this settings after uh after that only icon the or this book and all of this go badly in the kind of authorization that user will give us so if we use an under the scope section if we mentioned this this one which means they accused the uh the application will be builted public data from eBay and user will be able to view the public data from eBay in our application this other very popular API that we use that is inventory so if a seller want to see their inventory then we need to mention it is mandatory to mention this scope and if the seller belong to uh add more product in their inventory then we need to use this scope see it is saying View and manage your invent client offers so inventory and offer uh two things that come together and for that we use this spoke so we will have this scope parameter when we make a request and that time we need to mention these uh Scopes according to our requirement okay then this is for food order fulfillment okay sell finances there's so many things and they will check them a once we require them so one pill I forgot to mention is to show the test signing card so we have set up our redirect URL we got the application credentials as well so we have just test our signing page so I have a when we actually uh sign in in eBay so there is a regular sign-in page will come up like login with email ID to login with Google and login with Facebook so I have already logged in with Facebook that's why the login page has not come back now I have to Grant the application uh we have to authorize application for these permissions there the application is asking for these permissions I need to authorize them as a user I've been uh this is not my developer account this will be a separate user okay a regular eBay user login will do the login and they will need to provide us the permissions and where the permissions are coming from how will be where these financials will come from these permissions will come from the scope like what in this this is the signing page actually this page will be the sign in page and you can see the client ID is here and this pass type is able to Port redirect URI is equal to this scope is equal to this so from here till bottom here everything each you can see that they are all are like you are a kind of they are not like a URL so these are all actually uh okay so every scope defines the permissions that we can see here okay so whenever we will develop an application we will Define we that is why we need to define the Scopes so um if if we had only this scope the first scope right uh this https eBay api.ebay.com so if you want to use this uh URL only in the school till only one permission will come that is this so for different different permissions we will require a different effect scope as well and if a user will agree to this if a user will agree to this then our app will be able to use it but uh I'd not want to create multiple fake accounts in eBay so I'll click not now and it will redirect us to decline URL remember the decline URL like uh the auth decline URL will be in this reject page the reject page is like so we have pinned that to redirected to the the blind date and it is saying that authorization is canceled you can close the browser okay so currently I'm just declining however it was just showing you the uh the sign and uh the authentication and the authorization back okay so next step will be the coding part so I give day to day config.json file and this is the Json file where I will keep all my credentials save it like client ID client secret are you name and dividing if there are any other credentials then we will also save the same here as well so and then they'll be able to use it when they do the coding okay so in order to get the user access token we need to further to the step first is to get the user consent in this step we will create a custom login URL which can be specific to our application through this URL the user will log in to the eBay account and they will grant us the permission if they grant us the permission eBay will provide us an application token it is also called as a authorization code as when so in the second step we will exchange this authorization code for user access token and once we receive this user access token we should also keep record of them because sometimes the V need to revoke and for some other purposes as well we need to keep a record of those tokens okay so let's see how we can do this first is getting user consent eBay so we are here in this pitch so the idea has been have to go two parts so one is Target endpoint and one is HTTP query parameter so I'm going to use the production endpoint and in that we call painting the code so I have a variable for production and point so here and restored it I have already uh loaded my config.json file and I hear all the credentials in the form of dictionary so I saw that I can use it whenever it is required so let's see what are the next step the HTTP query parameters so query parameters wrong the direct URI it is called State this one I'm here and we can get the generic foreign and now we will change it according to our uh pretentious I'm creating an F string and this is a sandbox with us so I'm changing it to production URL production of an endpoint so if you guys see what we're able to be need to have brain is client ID uh the one is local but it is optional so if you can denote it is equal to login but it is optional so we'll move it redirect urine we use it and it is cost type is equal to Port so uh this is the port this is the authorization code we want like in this step we are telling eBay that we want authorization code okay in the next step is just called so and create a variable for it's called and the whole list will come this will be URL imported string of the space separated Scopes you remember if there are more than one scope they all will be separated by a single space only it means it will not be a python list or it will not be a Json you know uh array or you know or dictionary or Json itself you know so it will not be anything else it will be a simple string and all the Scopes will be space separated warning and only there will be single space okay so third last one is the state which is a customer State value we can use it but it's optional so I'm removing it there's no need for last end and came so these are the variables we will prepare here now let's mention these scopes so here where we can get the water sports we will put a user token page in the developer there is a user access token you visit the page here we have both Scopes here be quiet here is a Wonder stuff the Scopes that we can use in our application so the first word is for building the property data from eBay it is a simple one we can use this and as of Novel you also a single scope just in order to test over here in whether it is correctly or not so of nodex add on the variables property become client underscore ID insular than even port and his purpose rebuilders and his purpose is quicker it's called yes goes though have a string unit s I'll play so let's say this I have this thing is created and questions so I think like this static climate harness printing Lotto check it so this is the URL is created it will copy it will do incognito mode the desert ask us to provide see this is the name of our word uh this this is the display name that we have given every year okay now this is asking only single permission because we have added only one um is called in a lab in our tab okay So currently so it it means that our URL is working properly sorry like me let's see whatever it is redirected to over decline your repeats okay so let's add more Environ so like it shows that our URL is working connected now let's add memory virus or the sports review just use one by one let's use a go two threes boobs Golden Key stood and this is the telescope and using blockade be the single space and he told the three scopes we now let me bring to the wedding okay so the problem will be here is like because I'm using it in Greek Powershell so maybe it will throw some error because of full Ampersand has been used to try it on the command tone but of course CLD the name of the file is consented up high soybeans fine consensus.qm so now this is that gets created it is coffee so now we should have a three uh another there should be three items and under the permission heady yes so now we have these three permissions here foreign marketing activity levels campaigning listing okay this is the second one is for read online third one is two uh managing being let's set whatever Scopes medium used okay so yeah this one is this marketing one but this is a read only so it will only view over eBay marketing activities but it will view a view as well as manage so yeah we are able to lead to proper URL okay so in the next step uh what could you do is uh we will ask for the authorization Port so if we copy this URL and actually login into eBay as a user application then we will receive an authorization who received receive an authorization Accord and we can find the authorization report in the URL parameters so where they can find it I have copied the URL actually paste it here so let me see Port EBT documentation address to see on it getting user consent eBay so it is saying that uh the concentric list be it created this properly and all the at Grand Beach has been shown up and that Grant has been given naughty uh viewers should come something like this and in this URL there should be a parameter called code is equal to this this photo and now we need to find out this code and this is another parameter chord expires in uh what the documentation has to say about it in addition to the port value the response URL also contains an associated X expires in value that defines the number of seconds the authorization Port is when when it it means once we received this authorization report we we should use it within five minutes otherwise it will expire okay so let's see how the code word parameter looks like so I have copied it here Ebay sign in third party or or successful is able to prove and code is equal to this so this is the part which is OD is equal to this and then we have this and para and expires and 299 so this is our authorization board actually cool and now you can see that like there are so many if URL encoded letters I can say like this percent e are like this is pretty much a URL encoded authorization code so if we want to use it in our application we need to uh uncode it we need to convert it back into the string so for that we will not import ant because you already lived are you already there dot pi in code uncold okay so if we unport the board let me Predator board okay so we have print anything chord okay enter the code poor nightmare netmail please paste it there so now this is n't YouTube and how it is look how it looks like networking dictating so this is the code that we have you just created it is still the scene before on eBay so in the Second Step what was the second is the second step to exchange the authorization report for user it says to open so now we will go through the second part we will pass this code and they will get the user access token so net pay to pull the first uh it should be here itself like exchanging the authorization code for the instant stopper yeah so this is the page it's a novel what it is saying how we have to configure that it burst there should be another Target endpoint request header and request payload is here so now what our Target endpoint will be simply opposed to impressed copy and we use the production endpoint and for a wallet it is this word Exchange in B with a system okay electric first one unfortunately okay so now that the end point uh extoned X tones and clanked regular pursue destiny yeah at same night winning numbers will have content type which must be set to X application in the X the little longer imported and then authorization should be the word basic the word of BC followed by the base 64 encoded credential and which will be client ID subject plain Secret so they report B this phone just roughly about it and paste it here will say this is client ID Clancy dread so it's Corner variable CI which is client writing under spill client Secret this thing okay soon they're implicated and uh configuring the request payload which the grant type will be authorization code the redirect URI is the ru name as per our application set the portal URL imported authorization Port the port that we have just seen before the when when the user has authenticated us the user has authorized us so the port that we have received will take advantage warrant okay so this is uh age of the version how it looks like the method will be pushed and coined will be this titles has three parameter in it I can't even look like this okay okay now let's create a request so for that being in Puma in bulk r e q u t s t s I mean as simple requests and Bill nil okay solo pedis let's define headers as a vehicle what are the parameters in the header authorization for it is pretty much Jason likes who we need to do this and kill we go to Simon to change it and get this and be a bird of basic based 64 included credentials okay foreign Secret ions Secret so I'll let a string then be variable s then semicolon this Poland will be a stream only will leave it as is and then we'll be to client sleep hit so client secret we have in the form of whatever what was it all I'll take this tape this string so the thing is we need to convert this string into base 64. encoded so paste page 64 and infinity bytes not distinct so we need to convert into uh in byte form so let's say encoded underscale CA underscore CS uding Co seals Dot in code not has been converted into um bytes is 64 encoded a variable so let's put this it will be this 60th Court Blues and Report here till this substitute for card g64 in code 64. any chord I imported to the singles okay now uh under the authorization header we would need to pass so we would need to decode it back okay so let's decode the dance with so outside can be a string it should be a basic word basic followed by base640 imported CICS which is also been pre-coded so item Bella cadders should be cut it a little chip in my bedroom is coming today okay this is kind of not not exactly decent but it should be like okay so next thing is request about any okay data so data is equipping it Grant type or then this okay let's copy one of them here and redirected and click let me record correctly so there will not be any change on Mark Bourbons this is what we even receive from the Sun Sun here found the user input so it repeat and then create your array will be very so now we have a headers we have data now we can do the foreign [Music] what we didn't yeah and these are minus H Fitness which is and this is minus D so it should be data okay this is that is pass so I think beer is let's print the deal this pause you thought Json Splinter is fast.js so I hope everything is corrected run it so this is your originated protein penny side in yeah successfully completed so let me copy the URL Damascus hey grab the code value from here and we have the input training going on so fast pierced within you here power teasing inverted request error description a question is missing a required parameter or email fund but yeah it is my fight next is also B a string the code is available but the please are after being listed in class recording from the command point by tenor and send to our QA I have got the URL so authorization has been successfully completed my copy the authorization quote from here and foreign and it has a parameter snake access token access token one if you see uh actually access token is actually a very long string and it is around 20 or 39 and downstream so I have claimed it and it is also a very confidential uh token so uh that is also the reason I have uh uh I have removed many lines out of it so it usually start with the big 1.1 I think it is saying that it is a API version is a version 1.1 and it mostly end with a a equal to sign or equal to equal to sign 1.1 and ends with equal to sign and refresh token also start with P 1.1 and ends with equal sign okay so then we have X pass in so it is like two hours because one hour has 3600 seconds the refresh token expires in this many seconds it is like 1.5 years and the token type is user access token so it feels like we have successfully received the access token the user access token we have received successfully which we will use when we will use any eBay API so I think that's all for this video uh thank you for uh taking your time