Skip to content

Commit 52f40ad

Browse files
committed
Revert "V1 initial commit"
This reverts commit 732831b.
1 parent 732831b commit 52f40ad

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.DS_Store

-6 KB
Binary file not shown.

index.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@ const app = express()
1111

1212
app.get('/', (req, res) => {
1313

14-
// Step 1:
14+
// Step 1:
15+
// Check if the code parameter is in the url
16+
// if an authorization code is available, the user has most likely been redirected from Zoom OAuth
17+
// if not, the user needs to be redirected to Zoom OAuth to authorize
18+
19+
if (req.query.code) {
20+
21+
// Step 3:
1522
// Request an access token using the auth code
1623

17-
let url = 'https://zoom.us/oauth/token?grant_type=account_credentials&account_id=' + process.env.account_id;
24+
let url = 'https://zoom.us/oauth/token?grant_type=authorization_code&code=' + req.query.code + '&redirect_uri=' + process.env.redirectURL;
1825

1926
request.post(url, (error, response, body) => {
2027

2128
// Parse response to JSON
2229
body = JSON.parse(body);
2330

24-
// Logs your access tokens in the browser
31+
// Logs your access and refresh tokens in the browser
2532
console.log(`access_token: ${body.access_token}`);
26-
33+
console.log(`refresh_token: ${body.refresh_token}`);
34+
2735
if (body.access_token) {
2836

2937
// Step 4:
@@ -33,8 +41,7 @@ app.get('/', (req, res) => {
3341
// The `/me` context restricts an API call to the user the token belongs to
3442
// This helps make calls to user-specific endpoints instead of storing the userID
3543

36-
request.get('https://api.zoom.us/v2/users/' + process.env.user_id, (error, response, body) => {
37-
console.log(`User Id is ${process.env.user_id}`)
44+
request.get('https://api.zoom.us/v2/users/me', (error, response, body) => {
3845
if (error) {
3946
console.log('API Response Error: ', error)
4047
} else {
@@ -75,12 +82,12 @@ app.get('/', (req, res) => {
7582
}).auth(process.env.clientID, process.env.clientSecret);
7683

7784
return;
78-
79-
})
85+
86+
}
8087

8188
// Step 2:
8289
// If no authorization code is available, redirect to Zoom OAuth to authorize
83-
// res.redirect('https://zoom.us/oauth/authorize?response_type=code&client_id=' + process.env.clientID + '&redirect_uri=' + process.env.redirectURL)
84-
//})
90+
res.redirect('https://zoom.us/oauth/authorize?response_type=code&client_id=' + process.env.clientID + '&redirect_uri=' + process.env.redirectURL)
91+
})
8592

8693
app.listen(4000, () => console.log(`Zoom Hello World app listening at PORT: 4000`))

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"request": "^2.88.0"
2323
},
2424
"devDependencies": {
25-
"nodemon": "^2.0.15"
25+
"nodemon": "^2.0.2"
2626
}
27-
}
27+
}

0 commit comments

Comments
 (0)