# Error 405 when attempting to generate an OAuth access token

**URL:** <https://devforum.zoom.us/t/error-405-when-attempting-to-generate-an-oauth-access-token/78223>\
**Category:** Authentication\
**Created:** [November 2, 2022, 5:59pm UTC](https://devforum.zoom.us/t/error-405-when-attempting-to-generate-an-oauth-access-token/78223 "2022-11-02T17:59:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cody.nason](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cody.nason/32/42712_2.png) [@cody.nason](https://devforum.zoom.us/u/cody.nason)\
**Post date:** [November 2, 2022, 5:59pm UTC](https://devforum.zoom.us/t/error-405-when-attempting-to-generate-an-oauth-access-token/78223/1 "2022-11-02T17:59:00Z")

</div>

API Endpoint: [https://zoom.us/oauth/token](https://zoom.us/oauth/token)

I am trying to generate an access token for use in further API calls using Google Apps Script (Which is essentially Javascript).

The error that I am getting is: (I have added spaces to the links in order to make this post)  
"Exception: Request failed for h tt ps://zoom. us returned code 405. Truncated server response: \<!doctype html\> \<head prefix=“og: h tt p:// ogp. me/ns# fb: h tt p:// ogp. me/ns/fb# zoomvideocall: ht…”

My approach is as follows:

```auto
function getAccessToken()
{
  //declare clientID, secret, encoded header, and URL
  const username = "uxxxxxxxxxx";
  const password = "pxxxxxxxxxx";
  const accessHeader = ('Basic ' + Utilities.base64Encode(username + ':' + password));
  const accessOptions = { 'headers' : { 'method' : 'GET', 'Authorization' : accessHeader, muteHttpExceptions: true}}
  const postURL = "https://zoom.us/oauth/token?grant_type=account_credentials&account_id=xxxxxxxxxxxxxxxx";

  //send POST API request
  const postResponse = UrlFetchApp.fetch(postURL, accessOptions);
  var postJSON = postResponse.getContentText();
  var postData = JSON.parse(postJSON);

  //get access token
  var accessToken = postData.access_token;
}

```

I am not sure what I am doing wrong as I have read through the documentation for both Zoom and AppsScript regarding authentication and it looks to me that everything is correct. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [November 2, 2022, 6:34pm UTC](https://devforum.zoom.us/t/error-405-when-attempting-to-generate-an-oauth-access-token/78223/2 "2022-11-02T18:34:40Z")

</div>

@cody.nason,

Thank you for posting in the Zoom Developer Forum – I am happy to help. I am not familiar with Google Apps Script. However, if it is essentially Javascript, you should be able to reference our Sample OAuth apps for implementation guides. I’ve linked our OAuth and Server-to-Server Sample for your reference below.

# Zoom OAuth Hello World

> **[GitHub - zoom/zoom-oauth-sample-app: Sample Zoom Oauth App NodeJS app to call Zoom's...](https://github.com/zoom/zoom-oauth-sample-app)**
>
> Sample Zoom Oauth App NodeJS app to call Zoom's APIs

# Zoom Server-to-Server (s2s) Oauth Token Generation

> **[GitHub - zoom/server-to-server-oauth-token: Utility script to generate a Zoom Server-to-Server...](https://github.com/zoom/server-to-server-oauth-token)**
>
> Utility script to generate a Zoom Server-to-Server Oauth Token and copy to clipboard

Let me know if this helps.
