# How to enable Django WebApp to generate JWT or OAuth token for client applications

**URL:** <https://forum.djangoproject.com/t/how-to-enable-django-webapp-to-generate-jwt-or-oauth-token-for-client-applications/25659>\
**Category:** Forms & APIs\
**Created:** [November 26, 2023, 9:55am UTC](https://forum.djangoproject.com/t/how-to-enable-django-webapp-to-generate-jwt-or-oauth-token-for-client-applications/25659 "2023-11-26T09:55:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![technqvi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/technqvi/32/1851_2.png) [@technqvi](https://forum.djangoproject.com/u/technqvi)\
**Post date:** [November 26, 2023, 9:55am UTC](https://forum.djangoproject.com/t/how-to-enable-django-webapp-to-generate-jwt-or-oauth-token-for-client-applications/25659/1 "2023-11-26T09:55:17Z")

</div>

Hi  
_How can I issue access tokens to client applications like **JWT or OAuth** for machine-to-machine authentication ?_  
_Simply put, I have to issue a token to the Google Search module to access my web app._

For more detail.  
[Google Vertext-AI Search](https://cloud.google.com/generative-ai-app-builder/docs/add-widget#auth-token) requires **JWT or OAuth token** to authenticate to my Django app so that My Django Web can use Google Vertext-AI Search.

I have to copy a search widget to use on the page in my DjangoWeb as figure shown below.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/8/f/8f25b0f7d0e269e769c6515e2fd2a79dc07d5ecc.png)

Below is a Google search widget on my Django Web. Right now It has an error due to the token problem.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/7/7/77a9ec74a47c8bade1b30df50d9c84ddc1dfe2ad.png)

As far as I’ve done some research, I discovered [django-oauth-toolkit](https://django-oauth-toolkit.readthedocs.io/) , This python package is the most likely to match my requirement, I tried it but I cannot do the next step after registering application as the figure below.

I am not sure of the way to create a token by using this package as a link that I tried.  
[https://django-oauth-toolkit.readthedocs.io/en/latest/getting\_started.html#client-credential](https://django-oauth-toolkit.readthedocs.io/en/latest/getting_started.html#client-credential)

Additionally,I posted questions about this problem through django-oauth-toolkit gitbhub and googlecloudcommunity, you can read both to get more detail at the 2 following links.

1. [Vertex AI Search : How to configure/set JWT or OAuth token to integrate with Django Web](https://www.googlecloudcommunity.com/gc/AI-ML/Vertex-AI-Search-How-to-configure-set-JWT-or-OAuth-token-to/td-p/670330)

2. [Basic Question :How to get token correctly after complete registration](https://github.com/jazzband/django-oauth-toolkit/issues/1369)
