Skip to content

Commit

Permalink
Add docs for token generator function (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjin authored Jun 19, 2018
1 parent 2a83b31 commit 8791f4e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@ Wish to learn more about when, why and how you can use Token Exchange with the C
| User wants basic preview functionality + ability to edit own annotations| base_preview + annotation_edit |
| User wants basic preview functionality + ability to view all annotations + ability to edit own annotations| base_preview + annotation_view_all + annotation_edit|

Token Generator Function
------------------------
The Preview library optionally takes a token generator function instead of a string token. Using a token generator function allows you to dynamically determine what tokens Preview should use. For example, you can pass in different access tokens for each file or make sure your token is refreshed and valid before showing a preview. The token generator function should return a promise that resolves in either a single string token that applies to all of the files being previewed or a map of typed file IDs to access token for those files.

```javascript
// Example token generator function that resolves to a single access token
var singleTokenGenerator = function() {
return someApi.getToken().then(function(data) {
return data.token;
});
};

// Example token generator function that resolves to a map of tokens
var mapTokenGenerator = function() {
return Promise.resolve({
file_1234: 'some_token_abcd',
file_2345: 'some_token_bcde'
});
};
```

Viewers
-------
The name of a viewer can be one of the following `Document`, `Presentation`, `MP3`, `MP4`, `Dash`, `Image`, `Text`, `SWF`, `Image360`, `Video360`, `Model3d`, `CSV`, `Markdown`. Call `preview.getViewers()` to get the list of possible viewers.
Expand Down

0 comments on commit 8791f4e

Please sign in to comment.