# Trying to get access\_token, but 400 or 403 are returned.

**URL:** <https://devforum.zoom.us/t/trying-to-get-access-token-but-400-or-403-are-returned/62773>\
**Category:** API and Webhooks\
**Created:** [January 17, 2022, 2:36pm UTC](https://devforum.zoom.us/t/trying-to-get-access-token-but-400-or-403-are-returned/62773 "2022-01-17T14:36:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parkheesung](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/parkheesung/32/33970_2.png) [@parkheesung](https://devforum.zoom.us/u/parkheesung)\
**Post date:** [January 17, 2022, 2:36pm UTC](https://devforum.zoom.us/t/trying-to-get-access-token-but-400-or-403-are-returned/62773/1 "2022-01-17T14:36:06Z")

</div>

When access\_token is requested, it returns a 400 error for application/json and a 403 error for application/x-www-form-urlencoded.

I want to get the user’s access\_token in oAuth format and join them to an already opened meeting room.

The name of the app is LSKApp, and it is currently under review.

Please help me to move on to the next level.

Below is the source code.

==========================================

var oAuth = new oAuthParameter();  
oAuth.grant\_type = “authorization\_code”;  
oAuth.code = code;  
oAuth.redirect\_uri = $"{Request.Scheme}://{Request.Host}/Zoom/Auth/Token";

try  
{  
var httpWebRequest = (HttpWebRequest)WebRequest.Create(“[https://zoom.us/oauth/token](https://zoom.us/oauth/token)”);  
httpWebRequest.ContentType = “application/json”;  
httpWebRequest.Method = “POST”;

```
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes($"{this.siteConfig.Zoom.ClientID}:{this.siteConfig.Zoom.Secret}");
string crypto = Convert.ToBase64String(plainTextBytes);
httpWebRequest.Headers.Add("Authorization", $"Basic {crypto}");

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
	streamWriter.Write(oAuth.Serializer(state));
	streamWriter.Flush();
	streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
	string json_original = streamReader.ReadToEnd();
	if (!string.IsNullOrWhiteSpace(json_original))
	{
		result.Value = code;
		result.Success(1);
		result.Data = JsonConvert.DeserializeObject<ZoomApiAuthCallback>(json_original);
	}
	else
	{
		result.Error("return is Null or Empty.");
	}
}

```

}  
catch (Exception ex)  
{  
result.Error(ex);  
}

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [January 22, 2022, 2:24am UTC](https://devforum.zoom.us/t/trying-to-get-access-token-but-400-or-403-are-returned/62773/2 "2022-01-22T02:24:42Z")

</div>

@parkheesung Are you able to share the response body when the request fails? That should include more information on the error.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [February 21, 2022, 12:24pm UTC](https://devforum.zoom.us/t/trying-to-get-access-token-but-400-or-403-are-returned/62773/3 "2022-02-21T12:24:57Z")

</div>

Closed on February 21, 2022, 12:24pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
