S2s oauth - unsupported_grant_type

I just can’t for the life of me figure out what I am doing wrong. I can’t get any solution in any other topic to work. I’m trying to get the access_token from the …/oauth/token (url wasn’t allowed) endpoint.

I’m following the guide at: Server-to-Server OAuth

No matter what I do, I get the error: “unsupported_grant_type”

My JS attempt

async getAccessToken() {
            const data = qs.stringify({
                'grant_type': 'account_credentials',
                'account_id': this.accountId
            });

            const config = {
                method: 'post',
                url: 'https://zoom.us/oauth/token',
                headers: {
                    'Host': 'zoom.us',
                    'Authorization': 'Basic ' + Buffer.from(`${this.clientId}:${this.clientSecret}`).toString('base64'),
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                data: data
            };

            try {
                const response = await axios(config);
                return response.data;
            } catch (error) {
                console.error(error);
                throw error;
            }
    }

My postman attempt:
POST: …/oauth/token (url wasn’t allowed)

** image wasn’t allowed
But I was sending body as x-www-form-urlencoded
grant_type=account_credentials
account_id=****

The authentication seems correct because if I change it the error becomes invalid_client.

I also tried sending the grant_type as a param instead,
I also tried sending the post as form-data and json.

What am I missing?

So it turned out I was using meeting sdk app details.
Not the s2s app details.

Why this results in “unsupported_grant_type”? NO IDEA.

Hi @brendan_meetingsdk ,

Is this resolved?

Since, you’re passing grant type as account_credentials, it sounds like your intended use is for S2S. You can verify the exact set up you need for either in our public workspace:

OAuth 2 Postman Workspace: Postman

Server-to-Server: Postman

For S2S, no request body format is needed (unlike with OAuth 2.0):

I’m having a very similar issue. Not matter what I try I always get

{“reason”:“unsupported grant type”,“error”:“unsupported_grant_type”}

Trying to get account credentials as outlined in the S2S documentation. I downloaded the s2s.js app, plugged in my credentials (as opposed the PHP script I’ve written) and it gives the same error. My app says ready to install. Not sure what this means. Whenever i try to add the app, it calls the listed Oauth endepoint (not sure why) instead of just installing.

Any help would be greatly appreciated. Can’t seem to get to step one, authorization. And without this, obviously nothing else is going to work.

@brendan_meetingsdk ,

I’ve had success with something like this, hope it helps

// Function to fetch a bearer token
async function fetchBearerToken() {
  try {
    // Create a Basic Authorization header with client credentials
    const credentials = Buffer.from(`${process.env.ZOOM_S2S_CLIENT_ID}:${process.env.ZOOM_S2S_CLIENT_SECRET}`).toString('base64');
    const apiUrl = `https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${process.env.ZOOM_S2S_ACCOUNTID}`;
    
    // Define the token request parameters
    const tokenRequestData = {
      method: 'POST',
      url: apiUrl,
      headers: {
        'Authorization': `Basic ${credentials}`,
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      
    };

    // Send the token request
    const response = await axios(tokenRequestData);

    // Extract the access token from the response
    const accessToken = response.data.access_token;
    // Return 
    return accessToken;
   
  } catch (error) {
    return error.message;
  }
}

“Ready to install” designates that you have built one of the other app types such as OAuth or Zoom Apps app-type.

A Server to Server OAuth app type will say “Deactivated” or “Activated”.

Sorry, I should have been more clear. I was using the meeting sdk app credentials. Not the server-to-server oauth app credentials.

When changing to the correct credentials it worked fine

I am annoyed that the response was “unsupported_grant_type”. Which was wrong and had nothing to do with the actual problem. Which again, was wrong credentials.

Thanks for the replies.

I don’t know Andy’s situation. So can’t say if his issue is related or not.

Hi @brendan_meetingsdk thanks for clarifying. I’m happy it’s resolved!