# 400 Bad Request After Authorization Code

**URL:** <https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766>\
**Category:** Authentication\
**Tags:** api\
**Created:** [September 10, 2023, 1:39pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766 "2023-09-10T13:39:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![somasi2023](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/somasi2023/32/51886_2.png) [@somasi2023](https://devforum.zoom.us/u/somasi2023)\
**Post date:** [September 10, 2023, 1:39pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/1 "2023-09-10T13:39:02Z")

</div>

Hi All,  
Good Day!  
Getting a bad request for request token after a Authorization Code issue.  
General Overview for Proof of Concept  
So basically, what the application does, is create a meeting on BEHALF of USER ZOOM account. So, I created an **OAuth App** and follow this link: [OAuth for user authorized apps](https://developers.zoom.us/docs/integrations/oauth/),  
Scenario

1. it ask permission base on my scope request --working as expected

2. Once I click Allow it will redirect to my callback url method with Authorization Code–working as  
expected

3. When i try to request an access and refresh token base on the authorization code , I am getting  
a bad request.

Please see code below screenshot

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/9/2/92d92202f577909de34bec02086c34e1fc8563ef.png)

I did try also on postman  
Please see screenshot

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/4/542b0cc39195240bf219d53639c3ca6e6c9b9c8f.png)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/2/d/2d37c38c8e6b4d667676efcca15704d6011414e9.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![joshua.allen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/joshua.allen/32/51545_2.png) [@joshua.allen](https://devforum.zoom.us/u/joshua.allen)\
**Post date:** [September 10, 2023, 3:06pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/2 "2023-09-10T15:06:45Z")

</div>

I had a similar problem when first authenticating. Try adding  
'headers.Add(“Host”, “[zoom.us](http://zoom.us)”); ’  
in the headers dictionary. It’s not included in the chart in the documentation but is in the example.

Alternately, and I only say this because I made this mistake too, are you useing the code within an hour of receiving it?

---

<div class="post-metadata">

**Author:** ![somasi2023](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/somasi2023/32/51886_2.png) [@somasi2023](https://devforum.zoom.us/u/somasi2023)\
**Post date:** [September 11, 2023, 2:50am UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/3 "2023-09-11T02:50:13Z")

</div>

> [@joshua.allen](#):
>
> in the headers dictionary. It’s not included in the chart

I tried your suggestion, adding host in the header with the value “[zoom.us](http://zoom.us)”, I am still getting a bad request  
What version of api are you using?

---

<div class="post-metadata">

**Author:** ![joshua.allen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/joshua.allen/32/51545_2.png) [@joshua.allen](https://devforum.zoom.us/u/joshua.allen)\
**Post date:** [September 11, 2023, 3:51pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/4 "2023-09-11T15:51:50Z")

</div>

Hmm, dang I thought that might work. I think I’m using the same version as you. I followed the same documentation, created Oath app to interact with the rest API for meetings and chat. The only difference is that I’m a python developer and my C knowledge is a bit rusty. Any luck when adding the Host parameter in postman?

This may just be a python vs C difference but when sending the request through the request library the body is actually sent with the params argument not the the body. Maybe try switching from Body to Params on postman and see is that works?

---

<div class="post-metadata">

**Author:** ![somasi2023](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/somasi2023/32/51886_2.png) [@somasi2023](https://devforum.zoom.us/u/somasi2023)\
**Post date:** [September 11, 2023, 4:39pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/5 "2023-09-11T16:39:37Z")

</div>

> [@joshua.allen](#):
>
> ny luck when adding the

Can you send me your code for python if you dont mind please thank you

---

<div class="post-metadata">

**Author:** ![joshua.allen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/joshua.allen/32/51545_2.png) [@joshua.allen](https://devforum.zoom.us/u/joshua.allen)\
**Post date:** [September 11, 2023, 5:44pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/6 "2023-09-11T17:44:27Z")

</div>

Sure thing, Its wrapped in a class to handle some refresh token shenanigans’ so ignore the self’s.

params = {  
“code”: self.access\_code,  
“grant\_type”: “authorization\_code”,  
“redirect\_uri”: self.redirect\_uri,  
}  
response = requests.post(  
url=url, headers=self. **get\_authorization\_header** (), params=params  
) # sending the URL with the needed parameters  
token = None # initializing a token object  
if (  
response.ok  
): # if the call was successful update the token object, if not raise an error as no other operations can continue  
token = response.json()  
print(“Received token info”)  
self.token = token

with  
def **get\_authorization\_header** (self):  
return {  
“Host”: “[zoom.us](http://zoom.us)”,  
“Authorization”: “Basic {}”.format(self. **encode\_app\_credentials** ()),  
“Content-Type”: “application/x-www-form-urlencoded”,  
}

and

def **encode\_app\_credentials** (self):

auth = self.client\_id + “:” + self.client\_secret  
auth\_encode = auth.encode(“ascii”)  
auth\_b64 = base64.b64encode(auth\_encode)  
auth\_value = auth\_b64.decode(“ascii”)  
return auth\_value

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [September 15, 2023, 2:27pm UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/8 "2023-09-15T14:27:01Z")

</div>

Hi @somasi2023  
Can you take a look at this post and see if it helps:

> [@Guide: Making a Zoom API Call with OAuth Credentials in Postman](https://devforum.zoom.us/t/guide-making-a-zoom-api-call-with-oauth-credentials-in-postman/64538):
>
> To publish an app on the Zoom Marketplace you must create an [OAuth app](https://marketplace.zoom.us/docs/guides/build/oauth-app/). When you’re ready to test making API calls, download the latest version of Postman and import the Zoom API collections following the steps outlined [here](https://marketplace.zoom.us/docs/guides/guides/postman/using-postman-to-test-zoom-apis/). There are Three Ways to Set up OAuth in Postman to Make API Requests We’re going to go through three ways to set up our OAuth application credentials to successfully authorize and access the Zoom API to make requests. The “Easy” Difficulty OAuth 2.0 Set Up in Postman We’…

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [September 21, 2023, 4:07am UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/9 "2023-09-21T04:07:14Z")

</div>

> [@somasi2023](#):
>
> ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/9/2/92d92202f577909de34bec02086c34e1fc8563ef.png)
> 
> image925×325 53.4 KB

@somasi2023 ,

You have declared the headers, but it isn’t used in the actual \_httpClient.PostAysnc request?

---

<div class="post-metadata">

**Author:** ![somasi2023](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/somasi2023/32/51886_2.png) [@somasi2023](https://devforum.zoom.us/u/somasi2023)\
**Post date:** [November 1, 2023, 4:59am UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/10 "2023-11-01T04:59:48Z")

</div>

> [@chunsiong.zoom](#):
>
> ve declared the headers, but it isn’t used in the actual \_httpClient.PostAy

You are my savior @chunsiong.zoom You are the man…thank much

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [November 1, 2023, 5:23am UTC](https://devforum.zoom.us/t/400-bad-request-after-authorization-code/94766/11 "2023-11-01T05:23:28Z")

</div>

Closed on November 1, 2023, 5:23am UTC


