Skip to content

Commit b94e976

Browse files
author
Eric Koleda
committed
Merge pull request googleworkspace#4 from Spencer-Easton/ref/heads/master
Documented a few smaller functions in Readme
2 parents 95e6fe1 + 0d5c69e commit b94e976

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,42 @@ request in the "Authorization" header.
147147
...
148148
}
149149

150-
151150
## Compatiblity
152151

153152
This library was designed to work with any OAuth2 provider, but because of small
154153
differences in how they implement the standard it may be that some APIs
155154
aren't compatible. If you find an API that it does't work with, open an issue or
156155
fix the problem yourself and make a pull request against the source code.
156+
157+
## Other features
158+
####Reseting the Access Token
159+
160+
If you have an access token set and need to remove it from the property store
161+
you can remove it with the `reset()` function. Before you can call reset you need
162+
to set the property store.
163+
164+
function clearService(){
165+
OAuth2.createService('drive')
166+
.setPropertyStore(PropertiesService.getUserProperties())
167+
.reset();
168+
}
169+
170+
####Setting the Token Format
171+
172+
OAuth services can return a token in two ways: as JSON or an URL encoded
173+
string. You can set which format the token is in with `setTokenFormat(tokenFormat)`.
174+
There are two ENUMS to set the mode: `TOKEN_FORMAT.FORM_URL_ENCODED` and `TOKEN_FORMAT.JSON`.
175+
JSON is set as default if no token format is chosen.
176+
177+
function gitService() {
178+
return OAuth2.createService('git')
179+
.setAuthorizationBaseUrl('https://github.com/login/oauth/authorize')
180+
.setTokenUrl('https://github.com/login/oauth/access_token')
181+
.setClientId('...')
182+
.setClientSecret('...')
183+
.setProjectKey('...')
184+
.setCallbackFunction('authCallback')
185+
.setPropertyStore(PropertiesService.getUserProperties())
186+
.setScope('gist,repo,user')
187+
.setTokenFormat(OAuth2.TOKEN_FORMAT.FORM_URL_ENCODED);
188+
}

0 commit comments

Comments
 (0)