local loa=require "loa"
local authorization_endpoint = "https://accounts.google.com/o/oauth2/auth"
local token_endpoint = "https://accounts.google.com/o/oauth2/token"
local resource_endpoint = "https://www.googleapis.com/drive/v2"
local client_id = "Your Client ID"
local client_secret = "Your Client Secret"
local client=loa.new(authorization_endpoint, token_endpoint, resource_endpoint,
client_id, client_secret)
local redirect_uri ="http://localhost:8081/"
local scope ="https://www.googleapis.com/auth/drive.readonly.metadata"
local state =nil local default_query_parameters={key="value"}
local auth_uri=client:auth_uri(redirect_uri, scope, state,
default_query_parameters)
os.execute(string.format('start %s', auth_uri:gsub("&",'^&')))
local data=client._catch_redirect(redirect_uri)
code=data:match('code=([^%s&]+)')
client:request_token(nil, redirect_uri, {code=code})
for k,v in pairs(client) do print (k,v) end
local tbl=client:request("/files")
for k,v in pairs(tbl) do print(k,v) end