Skip to content

Commit 34a73b6

Browse files
authored
Merge pull request #20 from theta360developers/tutorial-2
added client_id and private key example to alternate tutorial
2 parents fc007b6 + a226e74 commit 34a73b6

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

docs/images/tutorial2/client_id.png

98.2 KB
Loading

docs/images/tutorial2/private_key.png

171 KB
Loading

docs/tutorial2.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
![private key](images/tutorial2/private_key.png)
67+
68+
The Client ID is shorter.
69+
70+
![client id](images/tutorial2/client_id.png)

mkdocs.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ site_author: Oppkey
44

55
theme:
66
name: material
7-
# features:
8-
# - navigation.instant
7+
features:
8+
- content.code.copy
99
logo: images/oppkey_logo.jpg
1010
favicon: images/oppkey_logo.jpg
1111
repo_name: [email protected]:theta360developers/ricoh-viewer.git
@@ -19,6 +19,7 @@ nav:
1919
- Contact: contact.md
2020
- Python Flask: python.md
2121
- Tutorial: tutorial.md
22+
- Alternative Tutorial: tutorial2.md
2223
- RICOH360 Cloud API: cloudapi.md
2324

2425
plugins:
@@ -32,3 +33,5 @@ markdown_extensions:
3233
- pymdownx.inlinehilite
3334
- pymdownx.snippets
3435
- pymdownx.superfences
36+
- admonition
37+
- pymdownx.details

0 commit comments

Comments
 (0)