# Requesting Access Token through Jquery AJAX

**URL:** <https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450>\
**Category:** API and Webhooks\
**Created:** [June 26, 2020, 7:43am UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450 "2020-06-26T07:43:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![umarzaman\_1](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@umarzaman\_1](https://devforum.zoom.us/u/umarzaman_1)\
**Post date:** [June 26, 2020, 7:43am UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/1 "2020-06-26T07:43:41Z")

</div>

Hi following is my code through which i am using to try to get the access toke but i am getting error  
"Access to XMLHttpRequest at ‘[https://zoom.us/oauth/token](https://zoom.us/oauth/token)’ from origin ‘[https://zoomintegration20200625133511.azurewebsites.net](https://zoomintegration20200625133511.azurewebsites.net)’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

## AquiredCode.html?code=hupsBKg4H2\_ILzNuuO2QhCiTOvJlmEXog:92 {readyState: 0, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …} jquery.min.js:2 POST [https://zoom.us/oauth/token](https://zoom.us/oauth/token) net::ERR\_FAILED’

(Document).ready(function () { var code = getUrlParameter('code'); if (code.length \> 0 && code != undefined) { (’#codeheading’).text(code);  
GetToken(code);  
}

```
    });
    function GetToken(code) {
        var clientID = 'xxxxxxxxxxxxxx6Q';
        var clientSecret = 'xxxxxxxxxxxxxxxxxxxxUr0'; 
        $.ajax({
            type: 'POST',
            url: 'https://zoom.us/oauth/token',
            crossDomin: true,
            headers: {
                'Authorization': 'Basic ' + btoa(clientID +':'+ clientSecret)
            },
            data: {
                'grant_type': 'authorization_code',
                'code': code,
                'redirect_uri': '..../AquiredCode.html'
            },
            success: function (data) {
                $('#codeheading').text(JSON.stringify(data));
            },
            error: function (error) {
                console.log(error);
            }
        });
    }
```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 29, 2020, 10:14pm UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/2 "2020-06-29T22:14:48Z")

</div>

Hey @umarzaman_1,

As our [OAuth docs state](https://marketplace.zoom.us/docs/guides/auth/oauth), you cannot call the Zoom API from the client side. You can use server side code like Node.js to make calls to the Zoom API.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![umarzaman\_1](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@umarzaman\_1](https://devforum.zoom.us/u/umarzaman_1)\
**Post date:** [July 1, 2020, 9:28pm UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/3 "2020-07-01T21:28:11Z")

</div>

Thanks for your reply Tommy. I was able to achieve it using RestSharp client in Webapi 2.0.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [July 6, 2020, 5:56pm UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/4 "2020-07-06T17:56:44Z")

</div>

You are welcome! Happy to hear you got it working! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![ofd.aws96](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ofd.aws96/32/12902_2.png) [@ofd.aws96](https://devforum.zoom.us/u/ofd.aws96)\
**Post date:** [August 2, 2020, 2:58pm UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/5 "2020-08-02T14:58:57Z")

</div>

Hi Understand zoom API couldn’t be called from client side like xhr or jquery .

But Why ? Like what If i still want to use it… i have simple html , Js static page & wan’t to get files using the list files api but getting this preflight cross origin error ☹

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 4, 2020, 5:30pm UTC](https://devforum.zoom.us/t/requesting-access-token-through-jquery-ajax/22450/6 "2020-08-04T17:30:00Z")

</div>

Hey @ofd.aws96,

The majority of APIs require server side or else you will get CORs errors.

Please educate here on the topic:

> **[3 Ways to Fix the CORS Error — and How Access-Control-Allow-Origin works](https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)**
>
> How to fix the infamous CORS error — the right way. Learn why the CORS error appears, and 3 solutions to fix it!

Thanks,  
Tommy
