|
| 1 | +# Alternate Tutorial for Minimal Application |
| 2 | + |
| 3 | +The RICOH360 Viewer requires two things to start: |
| 4 | + |
| 5 | +1. token for viewer |
| 6 | +2. contentId for the image you want to show |
| 7 | + |
| 8 | +```javascript linenums="1" hl_lines="4 8" title="index.html snippet" |
| 9 | +// instantiate viewer object |
| 10 | +const viewer = new RICOH360Viewer({ |
| 11 | + divId: "viewer", |
| 12 | + onFetchToken: () => "{{token}}", |
| 13 | +}); |
| 14 | +// start viewer with content |
| 15 | +viewer.start({ |
| 16 | + contentId: "{{contentId}}" |
| 17 | +}); |
| 18 | +``` |
| 19 | + |
| 20 | +## Setting up a virtual environment on Python |
| 21 | + |
| 22 | +Although not required, I recommend that you set up a virtual |
| 23 | +environment on Python. This avoids conflicting libraries on your main system |
| 24 | +Python. |
| 25 | + |
| 26 | +```text |
| 27 | +python -m venv venv |
| 28 | +source venv/bin/activate |
| 29 | +``` |
| 30 | + |
| 31 | +You should now see a `(venv)` prompt. |
| 32 | + |
| 33 | +```text |
| 34 | +(venv) craig@craigs-air practice % |
| 35 | +``` |
| 36 | + |
| 37 | +!!! tip inline end |
| 38 | + The Private Key and the Client Secret are not the same. You must |
| 39 | + get the Client ID, Client Secret, and Private Key from RICOH. The |
| 40 | + Private Key is for the Viewer. The Client Secret is for the content. |
| 41 | + |
| 42 | +## Viewer Token |
| 43 | + |
| 44 | +To generate the viewer token, you need the following: |
| 45 | + |
| 46 | +1. Client ID |
| 47 | +2. Private Key |
| 48 | + |
| 49 | +We will use PyJWT to generate the viewer token with the Private Key. |
| 50 | + |
| 51 | +### install PyJWT |
| 52 | + |
| 53 | +```text |
| 54 | +pip install PyJWT |
| 55 | +``` |
| 56 | + |
| 57 | +### Create `server.py` file |
| 58 | + |
| 59 | +Use VSCode or equivalent to create a file, `server.py`. |
| 60 | + |
| 61 | +At the top, include `import jwt`. |
| 62 | + |
| 63 | +Below the import, add your `PRIVATE_KEY` and `CLIENT_ID`. |
| 64 | +The Private Key is long. Put it in triple quotes. |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +The Client ID is shorter. |
| 69 | + |
| 70 | + |
0 commit comments