You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/typescript-node/docs/quickstart-auth.md
+17-24Lines changed: 17 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,38 @@
1
+
# Miro Node.js client quick start guide with OAuth 2.0 and Express
2
+
3
+
Build a simple app based on the Miro Node.js client library, the OAuth 2.0 code grant flow, and the Express JavaScript web framework.
4
+
1
5
## Goal
2
6
3
7
This quick start guide helps you familiarize yourself with the [Miro REST API 2.0](https://developers.miro.com/reference/api-reference) and the [OAuth 2.0 authorization code grant flow](https://www.oauth.com/oauth2-servers/server-side-apps/authorization-code/) by building a simple app that uses the Miro Node.js client library.
4
8
5
9
The guide also walks you through setting up a web server based on the [Express](https://expressjs.com/) framework. Express uses the Miro Node.js client library to implement authorization and token management for users.
6
10
7
-
At the end of the guide, you'll have built a simple app that prompts users for installation (this triggers the OAuth authorization flow), and then prints a list of all the boards the current user has access to.
11
+
At the end of the guide, you'll have built a simple app that prompts users for installation )this triggers the OAuth authorization flow), and then prints a list of all the boards the current user has access to.
8
12
9
13
## Prerequisites
10
14
11
15
Before you begin, make sure that:
12
16
13
17
- You have a [Miro account](https://miro.com/signup/).
14
18
- You're [signed in to Miro](https://miro.com/login/).
15
-
- Your Miro account has a [Developer team](https://developers.miro.com/docs/create-a-developer-team).
19
+
- Your Miro account has a [Developer team](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-1-create-a-developer-team-in-miro).
16
20
- Your development environment includes [Node.js 14.15 or a later version](https://nodejs.org/en/download/). \
17
21
To check the Node.js version on your system:
18
22
1. Open a terminal session.
19
23
2. In the terminal, run `node --version`.
20
24
21
-
It's a good idea to already go through the following steps in your Miro account settings:
25
+
It's a good to already go through the following steps in your Miro account settings:
22
26
23
-
1.[Create your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-1-create-your-app-in-miro)
24
-
2.[Configure your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-2-configure-your-app-in-miro)
27
+
1.[Create your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-2-create-your-app-in-miro)
28
+
2.[Configure your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-3-configure-your-app-in-miro)
25
29
3. In your app settings, go to **Redirect URI for OAuth2.0**; in the input field, enter the following URL: `http://127.0.0.1:4000/auth/miro/callback`; click **Add** to add it to the app [redirect URI list](https://www.oauth.com/oauth2-servers/redirect-uris/).
26
30
4. In your app settings, go to **App Credentials**, and save the values assigned to **Client ID** and **Client secret**. \
27
31
You'll need to use these values later.
28
32
29
33
## Build the app
30
34
31
35
After configuring the options in the previous section, you can start building the app.
32
-
33
36
### Step 1: create the project directory
34
37
35
38
1. Open a terminal session.
@@ -54,14 +57,14 @@ npm init -y
54
57
Install the Miro Node.js client library, the Express web framework, and its dependencies:
Now it's time to take care of the initial setup of your project:
63
66
64
-
- Create an`index.js` file.
67
+
- Create the`index.js` file.
65
68
- Import the dependencies that the app needs to run.
66
69
- Initialize the imported resources.
67
70
@@ -70,7 +73,7 @@ Now it's time to take care of the initial setup of your project:
70
73
To work with the Miro Node.js client library and the Express web framework, you need to import and initialize the corresponding libraries:
71
74
72
75
```javascript
73
-
const {Miro} =require('@mirohq/miro-api')
76
+
const {Miro} =require('@mirohq/miro-node')
74
77
constexpress=require('express')
75
78
constsession=require('express-session')
76
79
```
@@ -100,14 +103,10 @@ app.use(
100
103
)
101
104
```
102
105
103
-
> 🚧
104
-
>
105
-
> In production deployments, replace the secret with a randomly generated string.
106
+
⚠️ In production deployments, replace the secret with a randomly generated string. ⚠️
106
107
107
-
> 📘
108
-
>
109
-
> For the sake of simplicity, the quick start guide identifies users with session IDs.
110
-
> In production deployments, use actual user IDs, separate from session IDs. This avoids repeatedly prompting users to reinstall the app that they already installed in a previous, different session.
108
+
ℹ️ For the sake of simplicity, the quick start guide identifies users with session IDs. \
109
+
In production deployments, use actual user IDs, separate from session IDs. This avoids repeatedly prompting users to reinstall the app that they already installed in a previous, different session. ℹ️
111
110
112
111
### Step 5: redirect new users to the authorization page
113
112
@@ -203,13 +202,13 @@ Then, execute `index.js` with Node.js to start the app:
203
202
node index.js
204
203
```
205
204
206
-
To verify that the app is running, open [http://127.0.0.1:4000](http://127.0.0.1:4000) in a web browser.
205
+
To verify that the app is running, open http://127.0.0.1:4000 in a web browser.
0 commit comments