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

List of Necessary OAuth Granular Scopes #30

Open
GroovyDan opened this issue May 7, 2024 · 5 comments
Open

List of Necessary OAuth Granular Scopes #30

GroovyDan opened this issue May 7, 2024 · 5 comments

Comments

@GroovyDan
Copy link

Zoom recently release OAuth Granular Scopes to replace Classic Scopes (see: https://developers.zoom.us/docs/integrations/oauth-scopes-overview/). Does anyone have a list of the necessary granular scopes that need to be added to the OAuth app for this integration to pull data via the API? It appear you can no longer use the listed classic scopes.

@GroovyDan
Copy link
Author

Got it working. Here are the granular scopes I added:
image
image (1)

@AndrewLWilson
Copy link

@GroovyDan I'm trying to get this working with granular scopes using Stitch. Did you create a server-to-server Zoom app or a normal one? I created a server-to-server Zoom app but realized it does not use a refresh token.

@GroovyDan
Copy link
Author

GroovyDan commented Jun 7, 2024

@AndrewLWilson I created a normal one. Getting the initial refresh token can also be a pain. Here's some code that you can use to get one once you have the app set up:

"""
usage: get_refresh_token.py [-h] --client-id CLIENT_ID --client-secret CLIENT_SECRET --authorization-code AUTHORIZATION_CODE --redirect-uri REDIRECT_URI

Example:

$ poetry run python3 get_refresh_token.py \
    --client-id '[CLIENT-ID]' \
    --client-secret '[CLIENT-SECRET]' \
    --authorization-code '[AUTH-CODE]' \
    --redirect-uri [your-redirect-uri]
"""

import argparse
import json
from base64 import b64encode

import requests


def get_zoom_oauth_tokens(
    client_id: str, client_secret: str, code: str, oauth_redirect_uri: str
) -> dict:
    """
    Reference: https://developers.zoom.us/docs/integrations/oauth/#step-2-request-access-token
    """
    base64_auth_string = b64encode(
        f"{client_id}:{client_secret}".encode("ascii")
    ).decode("ascii")

    post_data = {
        "code": code,
        "grant_type": "authorization_code",
        "redirect_uri": oauth_redirect_uri,
    }

    headers = {
        "Authorization": f"Basic {base64_auth_string}",
        "Content-Type": "application/x-www-form-urlencoded",
    }

    print("\n\nFetching OAuth Tokens from https://zoom.us/oauth/token")
    response = requests.post(
        "https://zoom.us/oauth/token",
        data=post_data,
        headers=headers,
    )
    oauth_json = response.json()

    print(f"Response: {json.dumps(oauth_json, indent=2)}")

    return oauth_json


def main(
    client_id: str,
    client_secret: str,
    authorization_code: str,
    redirect_uri: str,
) -> None:
    oauth = get_zoom_oauth_tokens(
        client_id=client_id,
        client_secret=client_secret,
        code=authorization_code,
        oauth_redirect_uri=redirect_uri,
    )
    access_token, refresh_token = oauth["access_token"], oauth["refresh_token"]

    print(f"ACCESS TOKEN = {access_token}")
    print(f"REFRESH TOKEN = {refresh_token}")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--client-id", type=str, required=True)
    parser.add_argument("--client-secret", type=str, required=True)
    parser.add_argument("--authorization-code", type=str, required=True)
    parser.add_argument("--redirect-uri", type=str, required=True)
    args = parser.parse_args()

    main(
        client_id=args.client_id,
        client_secret=args.client_secret,
        authorization_code=args.authorization_code,
        redirect_uri=args.redirect_uri,
    )

@AndrewLWilson
Copy link

@GroovyDan wow, thank you so much for all of this! I'll try this out and let you know how it goes. Thanks you so much for your generosity, I owe you one!

@AndrewLWilson
Copy link

AndrewLWilson commented Jun 7, 2024

Success! I didn't know how to obtain the authorization_code for your script, but I was able to follow the readme of this and that logged the refresh token that Stitch requires. Thank you thank you thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants