-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathoauth_js.javascript.txt
26 lines (21 loc) · 1.53 KB
/
oauth_js.javascript.txt
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
┏━━━━━━━━━━━┓
┃ OAUTH ┃
┗━━━━━━━━━━━┛
OAUTH #OAuth2 client [S]
new OAUTH.OAuth2(CLIENT_ID, #Returns OAUTH2REQ
CLIENT_SECRET, DOMAIN, # - AUTH_URL_PATH (def: "/oauth/authorize"): only PATH after DOMAIN
AUTH_URL_PATH, TOKEN_URL_PATH)# - TOKEN_URL_PATH (def: "/oauth/access_token")
OAUTH2REQ.getAuthorizeUrl
(TOKEN_REQUEST) #Returns AUTH_URL?TOKEN_REQUEST (CLIENT_ID automatically inserted)
OAUTH2REQ.getOAuthAccessToken #Do either (according to args):
(REFRESH_TOKEN|CODE_STR, # - POST - TOKEN_URL__ REFRESH_REQUEST
REFRESH_REQUEST| # - POST - TOKEN_URL__ INTERMEDIARY_TOKEN_REQUEST: TOKEN_URL must actually be AUTH_URL
INTERMEDIARY_TOKEN_REQUEST, #CLIENT_ID and CLIENT_SECRET are automatically inserted
FUNC(ERROR_OBJ, TOKEN, #User-Agent: Node-oauth
REFRESH_TOKEN, ACCESS_TOKEN)) #ERROR_OBJ: statusCode, data (response)
OAUTH2REQ.get(URL, TOKEN, #Do GET - URL with OAuth Authorization:
FUNC(ERROR_OBJ, RESULT, RES)) # - ?access_token=TOKEN or, if OAUTH2REQ.useAuthorizationHeaderGET(true) was called,
# HTTP Header Authorization: Bearer
# - can also:
# - OAUTH2REQ.setAccessTokenName(VAR): instead of using "access_token"
# - OAUTH2REQ.setAuthMethod(STR): instead of using "Bearer"