Hi there!
I managed to get Google Oauth2 authentication working!!! Code is added here - in this case the code is for accessing and reading out your private calendars, but you can use this code in adapted form to use with all of Googles good bits!
For your info: Oauth turned out not to be so hard, but I have to say that all the documentation makes things so ****ing hard and confusing that it took me a while to get to grips with things.
For starters, here’s my code to share (pretty rough code, no error checking etc…), if I find some time I’ll be around to explain a bit further, if needed.
One thing I can tell you is that the Google Oauth2 playground is worth its weight in gold: you can do “live” testing of everything, and see exactly how the code should be formatted. After that it’s just “copy-paste” to modify this code.
local json = require( "json" ) -- Google Test local gClientID = "insert your own client ID here" local gClientSecret = "insert your own client secret here" local gRedirectURI = "insert your own redirect URI here - this may very well be just google.com, as long as you set the same URI in your google application credential settings" local gAuthorizationURL = "https://accounts.google.com/o/oauth2/auth" local gScope = "https://www.googleapis.com/auth/calendar" local gAccessTokenURL = "https://www.googleapis.com/oauth2/v3/token" local gGetCalendarListURL = "https://www.googleapis.com/calendar/v3/users/me/calendarList" local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 600, 600) local authorizationURL = string.format("%s?redirect\_uri=%s&response\_type=%s&client\_id=%s&scope=%s&approval\_prompt=%s&access\_type=%s", gAuthorizationURL, gRedirectURI, "code", gClientID, gScope, "force", "offline") webView:request(authorizationURL) local authorizationCode local gAccessToken local getCalendarListCallback = function(event) print(event.response) local decodedResponse = json.decode(event.response) print(#decodedResponse) end local getCalendarList = function(event) local parameters = {} local headers = {} headers["Authorization"] = "Bearer " .. gAccessToken parameters.headers = headers --parameters.body = string.format() network.request(gGetCalendarListURL, "GET", getCalendarListCallback, parameters) end local requestCredentialsCallback = function(event) print("rccb") print(event.response) local decodedResponse = json.decode(event.response) if decodedResponse["access\_token"] then gAccessToken = decodedResponse["access\_token"] print("access token set") getCalendarList() end end local requestCredentials = function(authorizationCode) local parameters = {} parameters.body = string.format("code=%s&redirect\_uri=%s&client\_id=%s&client\_secret=%s&scope=%s&grant\_type=%s", authorizationCode, gRedirectURI, gClientID, gClientSecret, gScope, "authorization\_code") network.request(gAccessTokenURL, "POST", requestCredentialsCallback, parameters) end local authorizationListener = function(event) if event.type == "loaded" then print(event.url) authorizationCode = string.match( event.url, 'code=(.+)' ) if authorizationCode then requestCredentials(authorizationCode) end end end webView:addEventListener( "urlRequest", authorizationListener )