Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo in readme #6

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
51587ae
config file for example purposes
Jun 26, 2018
ef38764
added package.json
Jun 26, 2018
dd86208
add index.js
Jun 26, 2018
55c60e3
index.js file for sample oaith call
Jul 10, 2018
ad466b3
added config.js file
Jul 10, 2018
99cc036
added package.json
Jul 10, 2018
e3039b1
add readme file
Jul 10, 2018
c63b623
Update README.md
michaelpurnellZoom Jul 10, 2018
47bd20a
Update README.md
michaelpurnellZoom Jul 10, 2018
38cdacd
Update README.md
michaelpurnellZoom Jul 10, 2018
bc8df82
Update README.md
michaelpurnellZoom Nov 29, 2018
d44022f
Changed the development environment to production
Apr 1, 2019
bda39a1
Display the response in browser
Apr 1, 2019
1e10fbb
Removed credentials
ShrijanaCodes Apr 1, 2019
3aa07c6
Merge pull request #2 from ShrijanaCodes/shrijana-oauth
ShrijanaCodes Apr 1, 2019
2af3078
Update README.md
michaeldharrington Jun 11, 2019
25a4cb7
one little correction
Dec 5, 2019
abbbcb4
Merge pull request #3 from turumtaev/master
tommygaessler Jan 29, 2020
ecded01
v2 init
michaeldharrington Mar 3, 2020
085dd8c
update readme
michaeldharrington Mar 3, 2020
e69da53
Merge pull request #4 from zoom/v2
michaeldharrington Mar 4, 2020
b81f5e9
updated support text
tommygaessler Jun 3, 2021
5d6696d
License and CoC fix
nodebotanist Jun 4, 2021
5ee0598
Merge pull request #5 from zoom/license-fix
nodebotanist Jun 7, 2021
19a38f1
V1 initial commit
ojusave Mar 4, 2022
e5cde54
Revert "V1 initial commit"
ojusave Mar 4, 2022
b7c7633
fix typo in readme
ffedoroff Apr 13, 2022
dc1ae8e
fix another typo in readme
ffedoroff Apr 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.env
package-lock.json

133 changes: 133 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use of this sample app is subject to our [Terms of Use](https://zoom.us/docs/en-us/zoom_api_license_and_tou.html)
133 changes: 132 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,132 @@
# zoom-jwt
# Zoom OAuth Hello World

Use of this sample app is subject to our [Terms of Use](https://zoom.us/docs/en-us/zoom_api_license_and_tou.html)

This is a Hello World app using an OAuth Marketplace App client ID and Secret to create an OAuth token, used to call the Zoom API.

Follow along with relevant Zoom OAuth documentation as we set this up:

1. [OAuth with Zoom](https://marketplace.zoom.us/docs/guides/authorization/oauth/oauth-with-zoom)
2. [Create an OAuth App](https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app)

## Setup app locally

Clone and install the app and it's dependencies. We'll be using [Express](https://www.npmjs.com/package/express) for a basic Node.js server, [dotenv](https://www.npmjs.com/package/dotenv) for our credentials, [requests](https://www.npmjs.com/package/requests) to make HTTP requests and [nodemon](https://www.npmjs.com/package/nodemon) for easier development refreshing.

```bash
git clone https://github.com/zoom/zoom-oauth-sample-app.git
```

```bash
cd zoom-oauth-sample-app && npm install
```

Run server:

```bash
npm run start
```

### Setup dotenv
Create a `.env` file in which to store your PORT, access credentials, and Redirect URL.

```bash
touch .env
```

Copy the following into this file, which we'll add your own values to:

```
clientID=
clientSecret=
redirectURL=
```

> Remember: Never share or store your client credentials publicly. Your `.env` is included in the `.gitignore` file to ensure these files won't be included in a git workflow.

## Install [ngrok](https://ngrok.com/)

During the OAuth flow, Zoom will need to know where to redirect a user after they have successfully authenticated and installed the app on their account.

For this we'll use [ngrok](https://ngrok.com/download), which creates a public link to a localhost development server.

Download and install ngrok, then follow the steps to connect your account.

Run ngrok on the same localhost port (4000):

```bash
~/./ngrok http 4000
```

This will generate a forwarding link. Copy this and add it into your `.env` file as the `redirectURL`. Keep ngrok running! If the linkage disconnects, we'll need to read a new redirectURL.

Example:

```
redirectURL=https://12345678.ngrok.io
```


## Create an OAuth App on the Zoom App Marketplace

Sign in to the Zoom App Marketplace and [Create an OAuth App](https://marketplace.zoom.us/develop/create?source=devdocs).

Creating this app will generate your OAuth Client ID and Secret needed to install on your account and get an access token.

Copy these credentials and add them to your `.env` file.

Example:

```
clientID=1234567890
clientSecret=13245678901234567890
redirectURL=https://12345678.ngrok.io
```

### Add your Redirect URL from ngrok to your app

Copy and paste your ngrok link into the Redirect URL for OAuth field, then click Continue.

### Fill out app information.

To install the app, we'll need to add some quick info on the app. Add in the following:

1. *Short Description*
2. *Long Description*
3. *Developer Name*
4. *Developer Contact*


> We won't need to add any Features to our app, but if we wanted to enable [Event Subscriptions](https://marketplace.zoom.us/docs/guides/tools-resources/webhooks#event-subscriptions) through Zoom Webhooks, we'd do it here.

### Add Scopes

OAuth is used to guarantee that an app only has access to the data you authorize. If an app does not have the required scope, it cannot call the API on your behalf.

To request data,we'll need to add a Scope to our app. The only data we need is for a user's profile information. Click **+ Add Scopes** and add *"View your user information"* (`user:read`). Click **Done** and continue on to the Installation page.

## Install app

With our app running on `localhost:4000`, a live redirectURL from ngrok, and proper scopes requested we can now install the app on our account.

Click **Install** or copy the Installation URL into a browser.

Zoom will now ask you to authorize the app on your account. Note that the app is requesting only the scope we've added.

> If you're not the admin on your Zoom account, the admin might require you to ask them for pre-approval to install this app. Submit a request to get this pre-approved by your account admin.

Authorizing the app will send you to the Redirect URL of your app, linked to our app running on localhost:4000.

Your express server will log your access_token, refresh_token and the API call response to get your user information.

In your browser, you'll see your Zoom profile data, with a JSON object showing the response. This API request was made using an `access_token` specific to this app and scopes.

## Next steps

Follow our documentation on OAuth with Zoom for more information on building a user-level app on the Zoom App Marketplace.

Code happy!

## Need help?

If you're looking for help, try [Developer Support](https://devsupport.zoom.us) or our [Developer Forum](https://devforum.zoom.us). Priority support is also available with [Premier Developer Support](https://zoom.us/docs/en-us/developer-support-plans.html) plans.
93 changes: 93 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Bring in environment secrets through dotenv
require('dotenv/config')

// Use the request module to make HTTP requests from Node
const request = require('request')

// Run the express app
const express = require('express')
const app = express()


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

// Step 1:
// Check if the code parameter is in the url
// if an authorization code is available, the user has most likely been redirected from Zoom OAuth
// if not, the user needs to be redirected to Zoom OAuth to authorize

if (req.query.code) {

// Step 3:
// Request an access token using the auth code

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

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

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

// Logs your access and refresh tokens in the browser
console.log(`access_token: ${body.access_token}`);
console.log(`refresh_token: ${body.refresh_token}`);

if (body.access_token) {

// Step 4:
// We can now use the access token to authenticate API calls

// Send a request to get your user information using the /me context
// The `/me` context restricts an API call to the user the token belongs to
// This helps make calls to user-specific endpoints instead of storing the userID

request.get('https://api.zoom.us/v2/users/me', (error, response, body) => {
if (error) {
console.log('API Response Error: ', error)
} else {
body = JSON.parse(body);
// Display response in console
console.log('API call ', body);
// Display response in browser
var JSONResponse = '<pre><code>' + JSON.stringify(body, null, 2) + '</code></pre>'
res.send(`
<style>
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap');@import url('https://necolas.github.io/normalize.css/8.0.1/normalize.css');html {color: #232333;font-family: 'Open Sans', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}h2 {font-weight: 700;font-size: 24px;}h4 {font-weight: 600;font-size: 14px;}.container {margin: 24px auto;padding: 16px;max-width: 720px;}.info {display: flex;align-items: center;}.info>div>span, .info>div>p {font-weight: 400;font-size: 13px;color: #747487;line-height: 16px;}.info>div>span::before {content: "👋";}.info>div>h2 {padding: 8px 0 6px;margin: 0;}.info>div>p {padding: 0;margin: 0;}.info>img {background: #747487;height: 96px;width: 96px;border-radius: 31.68px;overflow: hidden;margin: 0 20px 0 0;}.response {margin: 32px 0;display: flex;flex-wrap: wrap;align-items: center;justify-content: space-between;}.response>a {text-decoration: none;color: #2D8CFF;font-size: 14px;}.response>pre {overflow-x: scroll;background: #f6f7f9;padding: 1.2em 1.4em;border-radius: 10.56px;width: 100%;box-sizing: border-box;}
</style>
<div class="container">
<div class="info">
<img src="${body.pic_url}" alt="User photo" />
<div>
<span>Hello World!</span>
<h2>${body.first_name} ${body.last_name}</h2>
<p>${body.role_name}, ${body.company}</p>
</div>
</div>
<div class="response">
<h4>JSON Response:</h4>
<a href="https://marketplace.zoom.us/docs/api-reference/zoom-api/users/user" target="_blank">
API Reference
</a>
${JSONResponse}
</div>
</div>
`);
}
}).auth(null, null, true, body.access_token);

} else {
// Handle errors, something's gone wrong!
}

}).auth(process.env.clientID, process.env.clientSecret);

return;

}

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

app.listen(4000, () => console.log(`Zoom Hello World app listening at PORT: 4000`))
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "zoom-oauth-hello-world",
"version": "1.0.0",
"description": "Hello World app using an OAuth Marketplace App client ID and Secret to create an OAuth token, used to call the Zoom API.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [
"Zoom",
"Zoom App Marketplace",
"OAuth",
"Hello",
"World"
],
"author": "Michael Harrington",
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"request": "^2.88.0"
},
"devDependencies": {
"nodemon": "^2.0.2"
}
}