-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_google.lua
32 lines (24 loc) · 1.3 KB
/
example_google.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
oauth = require("oauth");
-- create a new consumer, you may generate x accesstokens from it
consumer = oauth.newConsumer({
consumer_key = "example.org",
consumer_secret = "secretGivenByGoogleCom",
request_token_url = 'https://www.google.com/accounts/OAuthGetRequestToken',
scope = 'https://spreadsheets.google.com/feeds/',
authorize_url= 'https://www.google.com/accounts/OAuthAuthorizeToken',
access_token_url= 'https://www.google.com/accounts/OAuthGetAccessToken',
token_ready_url='http://example.org/oauth/token_ready'
})
local requestToken = consumer.getRequestToken("oob");
print("Please open: ",requestToken.getAuthUrl())
print("and enter the pin code: ")
local pin = io.read()
local accessToken, err = consumer.getAccessTokenByPin(tostring(pin), requestToken.getToken(), requestToken.getTokenSecret())
print(err)
print(accessToken.getToken())
print(accessToken.getTokenSecret())
access, msg = accessToken.getAccess();
response, err = access.call("https://spreadsheets.google.com/feeds/spreadsheets/private/full", "GET", {})
-- use that one to check whether your authentification works:
--response, err = access.call("https://www.google.com/accounts/AuthSubTokenInfo", "GET", {})
print(response, err)