Skip to content

Commit 98fabae

Browse files
committed
Updated readme to remove lengthy example and reference complete sample code in samples directory.
1 parent e06dbf3 commit 98fabae

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

README.md

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -186,40 +186,16 @@ in these requests.
186186
'Authorization': 'Basic ' + Utilities.base64Encode(CLIENT_ID + ':' + CLIENT_SECRET)
187187
});
188188

189-
See the [FitBit sample](samples/FitBit.gs) for the compelte code.
189+
See the [FitBit sample](samples/FitBit.gs) for the complete code.
190190

191191
#### Modifying the access token payload
192192
Similar to Setting additional token headers, some services, such as the Smartsheet API, require you to [add a hash to the access token request payloads](http://smartsheet-platform.github.io/api-docs/?javascript#oauth-flow). The `setTokenPayloadHandler` method allows you to pass in a function to modify the payload of an access token request before the request is sent to the token endpoint:
193193

194194

195-
// Set the handler for adding Smartsheet's required SHA hash parameter to the payload:
196-
.setTokenPayloadHandler(smartsheetTokenHandler)
197-
...
198-
function smartsheetTokenHandler(payload) {
199-
var codeOrRefreshToken = payload.code ? payload.code : payload.refresh_token;
200-
var input = SMARTSHEET_CLIENT_SECRET + "|" + codeOrRefreshToken;
201-
var hash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256,
202-
input,
203-
Utilities.Charset.UTF_8);
204-
hash = hash.map(function(val) {
205-
// Google appears to treat these as signed bytes, but we need them unsigned...
206-
if (val < 0)
207-
val += 256;
208-
var str = val.toString(16);
209-
// pad to two hex digits:
210-
if (str.length == 1)
211-
str = '0' + str;
212-
return str;
213-
});
214-
payload.hash = hash.join("");
215-
// Smartsheet doesn't need the client secret sent (secret is verified by the hash)
216-
if (payload.client_secret) {
217-
delete payload.client_secret;
218-
}
219-
return payload;
220-
}
195+
// Set the handler for modifying the access token request payload:
196+
.setTokenPayloadHandler(myTokenHandler)
221197

222-
198+
See the [Smartsheet sample](samples/Smartsheet.gs) for the complete code.
223199

224200
#### Service Accounts
225201

0 commit comments

Comments
 (0)