Authenticating Oauth2 in Google App Script

I'm sure this is a pretty basic question. I'm pretty new to Lightspeed and setting up Oauth stuff. Not so new to Google App Script and I have set up a couple Oauth links before in order to integrate back and forth with other APIs. I'm a little bit lost on how to set it up properly for Lightspeed however.
I've registered for an Oauth client and gotten my ID and Secret. I've gone over the PHP example from github. However, in the Google environment those scripts aren't exactly plug and play and I'm not sure the best way to go forward.
I know it's possible to set this up and I'll keep at it, but does anyone here have first hand experience setting this up or have a link to any kind of example or guide?
Tags:
1 comment
Hey @CalebMonty42,
You have the option to do part of the authentication manually (i.e. getting your access and refresh token) and then have a cron job automate the refreshing of the token
Step 1:
Register your client.
In the redirectURI put in a server you control, like http://localhost.com
Step 2:
Generate the url that determines the level of authentication you're going to give the app
https://cloud.lightspeedapp.com/oauth/authorize.php?responsetype=code&clientid={your_client_id}&scope=employee:all
Step 3:
Login with that URL and authenticate
Step 4:
Get temporary code that's generated, and within 30 seconds complete step 5
Step 5:
Make a access token request with your client_id, clientsecret, your newly generated temporary code and the granttype specified as "authorization_code"
Step 6:
Let store your refresh token and your access token in the properties service:
https://developers.google.com/apps-script/reference/properties/ and refresh it on a Cron Job via installable triggers:
https://developers.google.com/apps-script/guides/triggers/installable
Then you can append the data to the sheet as desired!
You can review the authentication instructions here:
https://developers.lightspeedhq.com/retail/authentication/authentication-overview/
Hope this helps!
Adrian Samuel
Software Developer
Lightspeed HQ