# Access Token Response in HTML instead JSON

**URL:** <https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986>\
**Category:** Authentication\
**Tags:** api\
**Created:** [January 5, 2023, 11:16am UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986 "2023-01-05T11:16:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoom.dev1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zoom.dev1](https://devforum.zoom.us/u/zoom.dev1)\
**Post date:** [January 5, 2023, 11:16am UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/1 "2023-01-05T11:16:42Z")

</div>

We are experiencing a strange behavior while refreshing Access token in the OAuth API calls

Here is the workflow

1. Send API call to create meeting using POST /users/{userId}/meetings

2. If access token is expired, we get status code as 401.

3. Send post call to refresh access token as described in this article [https://marketplace.zoom.us/docs/guides/auth/oauth/#refreshing-an-access-token](https://marketplace.zoom.us/docs/guides/auth/oauth/#refreshing-an-access-token)

4. We receive status code of 200 and response in HTML format instead of JSON.

We require JSON response 100% of the time. This issue is not happening when we are getting the first access token after using the Publishing URL [https://marketplace.zoom.us/docs/guides/auth/oauth/#getting-an-access-token](https://marketplace.zoom.us/docs/guides/auth/oauth/#getting-an-access-token). This occurs only when refreshing the access token after receiving status 401. We are using the exact same header in both scenarios.

Here is the header:

```auto
'Content-type' => 'application/json',
 'Accept' => 'application/json, application/xml'
'Authorization' => 'Basic Client_ID:Client_Secret'

```

Any insights will be helpful.

Thanks

Update:  
HTTP request of refreshing access token below

```auto
Blob headerValue = Blob.valueOf('Client_ID:Client_Secret');
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);

String endpointBuild = 'https://zoom.us/oauth/token?refresh_token=' + refreshToken + '&grant_type=refresh_token';

HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint(endpointBuild);
request.setHeader('Content-type', 'application/json');
request.setHeader('Accept', 'application/json, application/xml);
request.setHeader('Authorization', 'Basic ' + authorizationHeader);

HttpResponse httpResponse = new Http().send(request);

```

---

<div class="post-metadata">

**Author:** ![freelancer.nak](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freelancer.nak/32/40968_2.png) [@freelancer.nak](https://devforum.zoom.us/u/freelancer.nak)\
**Post date:** [January 5, 2023, 11:23am UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/2 "2023-01-05T11:23:48Z")

</div>

@zoom.dev1, Hope you will be fine. You are using which request package to call Zoom REST API e.g axios, HTTPClient etc.

---

<div class="post-metadata">

**Author:** ![zoom.dev1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zoom.dev1](https://devforum.zoom.us/u/zoom.dev1)\
**Post date:** [January 5, 2023, 11:32am UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/3 "2023-01-05T11:32:30Z")

</div>

We are using Salesforce HTTP class. Solution is built solely on Salesforce

---

<div class="post-metadata">

**Author:** ![zoom.dev1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zoom.dev1](https://devforum.zoom.us/u/zoom.dev1)\
**Post date:** [January 5, 2023, 12:02pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/5 "2023-01-05T12:02:48Z")

</div>

Yes absolutely. It is as below

```auto
request.setHeader('Content-type', 'application/json');
request.setHeader('Accept', 'application/json, application/xml);
request.setHeader('Authorization', 'Basic' + Client_ID:Client_Secret);

```

These headers are working correctly when we use them for initial access token. It only occurs when we are refreshing the access token

---

<div class="post-metadata">

**Author:** ![freelancer.nak](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freelancer.nak/32/40968_2.png) [@freelancer.nak](https://devforum.zoom.us/u/freelancer.nak)\
**Post date:** [January 5, 2023, 12:06pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/6 "2023-01-05T12:06:49Z")

</div>

How you are refreshing token by passing in query parameteres?

---

<div class="post-metadata">

**Author:** ![freelancer.nak](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freelancer.nak/32/40968_2.png) [@freelancer.nak](https://devforum.zoom.us/u/freelancer.nak)\
**Post date:** [January 5, 2023, 12:33pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/7 "2023-01-05T12:33:26Z")

</div>

@zoom.dev1, Are you encoding client\_id:client\_secret base64 string.

As here is the NodeJS sample

```auto
const refresh_token=async (refresh_token)=>
{
    var data = qs.stringify({
        refresh_token: refresh_token,
        grant_type: 'refresh_token',
        redirect_uri: process.env.ZOOM_OAUTH_REDIRECT_URI
    });

    var config = {
        method: 'post',
        url: 'https://zoom.us/oauth/token',
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Authorization": "Basic " + Buffer.from(`${process.env.ZOOM_CLIENT_ID}:${process.env.ZOOM_CLIENT_SECRET}`).toString('base64')
        },
        data: data
    };

    var result = await axios(config)
        .then(function (response) {
            return response;
        })
        .catch(function (error) {
            return error;
        });

    return result;
}

```

---

<div class="post-metadata">

**Author:** ![gauravdev](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@gauravdev](https://devforum.zoom.us/u/gauravdev)\
**Post date:** [January 5, 2023, 12:43pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/8 "2023-01-05T12:43:31Z")

</div>

I am using Server to server oauth app, i have a php code by using guzzlehttp client i am able to get the access code but i am geeting a error html and also this error  
  
`300`  
Unsupported Content Type  
  
when i user this end point [https://api.zoom.us/v2/users/me/meetings](https://api.zoom.us/v2/users/me/meetings)  
the body is like this  
{  
“topic”: “Testing-02”,  
“type”: “2”,  
“start\_time”: “2023-01-06”,  
“duration”: “60”,  
“timezone”: “Asia/kolkata”,  
“password”: “123”,  
“agenda”: “Testing for zoom meeting”,  
"settings: {  
‘host\_video’: “true”,  
‘join\_before\_host’: “true”,  
‘mute\_upon\_entry’: “true”,  
‘participant\_video’: “true”,  
‘breakout\_room’: {  
‘enable’ : “true”  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![zoom.dev1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zoom.dev1](https://devforum.zoom.us/u/zoom.dev1)\
**Post date:** [January 5, 2023, 2:03pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/9 "2023-01-05T14:03:43Z")

</div>

@freelancer.nak

I have updated my post above as well with this code

```auto
Blob headerValue = Blob.valueOf('Client_ID:Client_Secret');
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);

String endpointBuild = 'https://zoom.us/oauth/token?refresh_token=' + refreshToken + '&grant_type=refresh_token';

HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint(endpointBuild);
request.setHeader('Content-type', 'application/json');
request.setHeader('Accept', 'application/json, application/xml);
request.setHeader('Authorization', 'Basic ' + authorizationHeader);

HttpResponse httpResponse = new Http().send(request);

```

We are receiving the refreshed Access Token; however, that response is coming in as HTML format instead of JSON format  
Thank you for the replies

---

<div class="post-metadata">

**Author:** ![freelancer.nak](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/freelancer.nak/32/40968_2.png) [@freelancer.nak](https://devforum.zoom.us/u/freelancer.nak)\
**Post date:** [January 5, 2023, 2:22pm UTC](https://devforum.zoom.us/t/access-token-response-in-html-instead-json/80986/11 "2023-01-05T14:22:34Z")

</div>

Please use this header → ` "Content-type": "application/x-www-form-urlencoded"`
