@@ -153,7 +153,7 @@ fix the problem yourself and make a pull request against the source code.
153
153
154
154
## Other features
155
155
156
- #### Resetting the Access Token
156
+ #### Resetting the access token
157
157
158
158
If you have an access token set and need to remove it from the property store
159
159
you can remove it with the ` reset() ` function. Before you can call reset you
@@ -165,26 +165,26 @@ need to set the property store.
165
165
.reset();
166
166
}
167
167
168
- #### Setting the Token Format
168
+ #### Setting the token format
169
169
170
170
OAuth services can return a token in two ways: as JSON or an URL encoded
171
171
string. You can set which format the token is in with
172
172
` setTokenFormat(tokenFormat) ` . There are two ENUMS to set the mode:
173
173
` TOKEN_FORMAT.FORM_URL_ENCODED ` and ` TOKEN_FORMAT.JSON ` . JSON is set as default
174
174
if no token format is chosen.
175
175
176
- function gitService() {
177
- return OAuth2.createService('git')
178
- .setAuthorizationBaseUrl('https://github.com/login/oauth/authorize')
179
- .setTokenUrl('https://github.com/login/oauth/access_token')
180
- .setClientId('...')
181
- .setClientSecret('...')
182
- .setProjectKey('...')
183
- .setCallbackFunction('authCallback')
184
- .setPropertyStore(PropertiesService.getUserProperties() )
185
- .setScope('gist,repo,user')
186
- .setTokenFormat(OAuth2.TOKEN_FORMAT.FORM_URL_ENCODED);
187
- }
176
+ #### Setting additional token headers
177
+
178
+ Some services, such as the FitBit API, require you to set an Authorization
179
+ header on access token requests. The ` setTokenHeaders() ` method allows you
180
+ to pass in a JavaScript object of additional header key/value pairs to be used
181
+ in these requests.
182
+
183
+ .setTokenHeaders({
184
+ 'Authorization': 'Basic ' + Utilities.base64Encode(CLIENT_ID + ':' + CLIENT_SECRET )
185
+ });
186
+
187
+ See the [ FitBit sample ] ( samples/FitBit.gs ) for the compelte code.
188
188
189
189
#### Service Accounts
190
190
@@ -199,5 +199,5 @@ This process allows a Google Apps for Work/EDU domain administrator to grant an
199
199
application access to all the users within the domain. When the application
200
200
wishes to access the resources of a particular user, it uses the service account
201
201
authorization flow to obtain an access token. See the sample
202
- [ ` GoogleServiceAccount.gs ` ] ( https://github.com/googlesamples/apps-script-oauth2/blob/master/ samples/GoogleServiceAccount.gs)
203
- for more information.
202
+ [ ` GoogleServiceAccount.gs ` ] ( samples/GoogleServiceAccount.gs ) for more
203
+ information.
0 commit comments