hey i'm megan a developer advocate here,with shopify and today we'll be using an,access token generated by shopify to,request product information through the,admin api,if you're familiar with web development,you know that apis are sets of protocols,and rules used to define how you can,integrate your application with this,source the apis provided by shopify are,no different and they are the primary,way that you as an app developer can,integrate your app with shopify,shopify has a few apis available that,you can use but today we will be,focusing on the admin api since we only,want product information you can find,out more about the different types of,apis available if you watch this video,by my friend liz she goes into detail,more about each one,the admin api gives your app the ability,to read,and write shopify store information this,includes products orders shipping and,more and because of this all requests to,the admin api need to be authenticated i,will be demonstrating how to make,authenticated requests using both curl,and a plugin for vs code called,thunderclient,you can use whatever htp client that you,prefer i'm not going to pick sides in,this case,so first in the shopify admin,i'm going to,create a new application,notice here that this is a custom,application and this is fine for my use,case because it's only going to be,installed on the singular store but you,can also create public apps as well,we'll call this app test api,app,cool now the app's created from here,part of the authentication and,authorization process involves us,telling shopify exactly what information,we would like to request through their,apis and we can do this by specifying,the api scopes,we can configure these scopes here and,for the purposes of this demo i'm only,going to be selecting the read product,scope because all i need to do for this,app is read product information,here you can see the access token that,is generated by shopify now that the app,is installed we will send this access,token along in the header for any http,request that we make to the admin api,this is how shopify will identify and,authorize us to get the information that,we are asking for,now that the app is installed and ready,to go let's take a look at how exactly,we might request that information,you can see here that the url for the,graphql admin api endpoint is as follows,we would fill in the store name here,um this specifies the admin api this is,the version i'm just going to stick with,the latest that's fine with me,and then we're going to be specifying,the graphql endpoint we do have rest,endpoints available too,cool now that we know what the endpoint,is for the information that we're,looking for let's take a look at how we,might make a curl request to this,endpoint while still including our,access token in the header,so in eye term here i'm going to go,ahead and just make a normal curl,request i'm going to fill in the shopify,store as the,first part of that url like we saw in,the documentation and of course the,application type is application json,from here we have to include the access,token as a header like i mentioned so,that shopify can identify us,and the name of this header is shopify,x shopify access token,it's important to keep your access token,secret you wouldn't want to commit this,to get or share it with anyone because,it is how shopify identifies you in the,future the next step is to actually,define the query that we want to send to,graphql,in this case i'm just going to ask for,the first 10 products and their ids and,titles that's a simple enough example to,prove that this authentication token,will work,all right so as you can see here this is,the,product information for the first 10,products in my shopify store including,their ids and titles,you can see if i,try to make this same request again and,let's say i accidentally mess up the,access token,i should get an error message that's,pretty clear,and there we go,the invalid api,key or access token unrecognized and,valid wrong password all that,information is telling me that my access,token is incorrect and shopify was,unable to authenticate me to make this,request,all right so we're going to switch over,to vs code and do the same thing that we,just did in curl but we're going to use,thunder client instead so because it's a,graphql query we are going to switch it,to a post,we'll use that same endpoint that we had,before that includes my shopify store,url,so we can just switch to the header tab,here and include the x shopify access,token,and we'll paste in the value that of the,same token that we used in that curl,request so now in the body tab we can,define exactly what we're asking for,from the graphql endpoint we'll make the,same query as we did in the curl request,one thing i did notice is that you do,have to send over a variable object in,order to make a request using this,graphql editor so because everything is,just static in this query i'll just send,along an empty object as the variables,and you can see here on the right that,this is the first 10 products in my,store including their id and their title,if i were to,mistakenly add the wrong access token or,something got mixed up with the header,you will see the same error that we saw,in the curl,all right that covers it,that's all the steps that you need to,generate an api access token in order to,request information from your shopify,admin api,you can use tools like curl or thunder,client or whichever http client that you,prefer postman insomnia the,options are endless but practicing these,api calls before you actually start your,development is a great way to speed up,your actual development to make sure,that your api requests are functioning,properly and you're getting the data,back correctly,if you're building out your application,with ruby python php or node shopify has,some great client libraries as well that,can help simplify this process and you,can check them out here using the,link in the description below,for more information about shopify,development subscribe to this channel,review documentation on shopify.dev and,join the community by asking questions,in discord slack or joining our,community forums,thanks see you there
Congratulation! You bave finally finished reading how to get access to shopify server and believe you bave enougb understending how to get access to shopify server
Come on and read the rest of the article!