# HTTPError during token refresh: 400, {"reason":"Invalid Token!","error":"invalid\_grant"}

**URL:** <https://devforum.zoom.us/t/httperror-during-token-refresh-400-reason-invalid-token-error-invalid-grant/100909>\
**Category:** Authentication\
**Created:** [December 29, 2023, 12:04am UTC](https://devforum.zoom.us/t/httperror-during-token-refresh-400-reason-invalid-token-error-invalid-grant/100909 "2023-12-29T00:04:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rh.lh.314](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@rh.lh.314](https://devforum.zoom.us/u/rh.lh.314)\
**Post date:** [December 29, 2023, 12:04am UTC](https://devforum.zoom.us/t/httperror-during-token-refresh-400-reason-invalid-token-error-invalid-grant/100909/1 "2023-12-29T00:04:06Z")

</div>

Hi,

I’m trying to use django allauth to connect my app to zoom api. I have been able to authenticate my user account but am having issues with performing actions without  
a proper access token. In order to get a valid access token and refresh token, I am trying to retrieve both of them, but I think I am not submitting the correct refresh token. This is how I am attempting to find the initial refresh token:

refresh\_token = SocialToken.objects.get(account\_\_user=request.user, account\_\_provider=‘zoom’)

#These are the different attributes listed for my SocialToken object  
print(refresh\_token.id)  
print(refresh\_token.app)  
print(refresh\_token.account)  
print(refresh\_token.token)  
print(refresh\_token.token\_secret)  
print(refresh\_token.expires\_at)

token\_url = f’[https://zoom.us/oauth/token](https://zoom.us/oauth/token)’  
headers = {  
‘Authorization’: ‘Basic ’ + base64.b64encode(f’{client\_id}:{client\_secret}'.encode(‘utf-8’)).decode(‘utf-8’),  
‘Content-Type’: ‘application/x-www-form-urlencoded’,  
}  
data = {  
‘grant\_type’: ‘refresh\_token’,  
‘refresh\_token’ : refresh\_token.token,  
}  
data\_encoded = “&”.join([f"{key}={value}" for key, value in data.items()])  
response = requests.post(token\_url, headers=headers, data=data\_encoded)

I seem to be getting two errors, which I assume are related:  
400 Client Error: Bad Request for url: [https://zoom.us/oauth/token](https://zoom.us/oauth/token)  
Error during token refresh: 400, {“reason”:“Invalid Token!”,“error”:“invalid\_grant”}

I have added the user:read, recording:read, and recording:write scopes. Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [January 2, 2024, 6:45pm UTC](https://devforum.zoom.us/t/httperror-during-token-refresh-400-reason-invalid-token-error-invalid-grant/100909/2 "2024-01-02T18:45:44Z")

</div>

> [@rh.lh.314](#):
>
> I have been able to authenticate my user account but am having issues with performing actions without  
> a proper access token. In order to get a valid access token and refresh token, I am trying to retrieve both of them, but I think I am not submitting the correct refresh token.

You can only refresh an access token once you’ve retrieved a valid OAuth access token.

When you retrieve a an access token, a refresh token will also be shared in the response.

> [@rh.lh.314](#):
>
> headers = {  
> ‘Authorization’: ‘Basic ’ + base64.b64encode(f’{client\_id}:{client\_secret}'.encode(‘utf-8’)).decode(‘utf-8’),  
> ‘Content-Type’: ‘application/x-www-form-urlencoded’,  
> }

This part is accurate, but you are missing the appropriate request body parameters. You can see them here in our docs: [OAuth for user authorized apps](https://developers.zoom.us/docs/integrations/oauth/#step-2-request-access-token)

You may also use our public workspace for assistance: [Postman](https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-82698a23-7af5-4f3f-bf2e-a62c3eb8903d?ctx=documentation&tab=body)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/7/b705282e024f060c288d9f9d112ca2768b3ea092.png)

Review the [Overview](https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/overview) for guidance on using the workspace.
