prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add a feature to show the authentication token to the user on the MyProfile Page
  **Deliverables:**
  
  - [x] Add API endpoint to fetch or create (if doesn't exists) the token from database.
  
  - [x] Add Frontend with features to show, copy and download the token in JSON format
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/accounts/urls.py`
  Content:
  ```
  1 from django.conf.urls import url
  2 
  3 from . import views
  4 
  5 urlpatterns = [
  6 
  7     url(r'^user/disable$', views.disable_user, name='disable_user'),
  8 
  9 ]
  10
  ```
  
  Path: `apps/accounts/views.py`
  Content:
  ```
  1 from django.contrib.auth import logout
  2 
  3 from rest_framework.response import Response
  4 from rest_framework import permissions, status
  5 from rest_framework.decorators import (api_view,
  6                                        authentication_classes,
  7                                        permission_classes,)
  8 from rest_framework_expiring_authtoken.authentication import (ExpiringTokenAuthentication,)
  9 
  10 
  11 @api_view(['POST'])
  12 @permission_classes((permissions.IsAuthenticated,))
  13 @authentication_classes((ExpiringTokenAuthentication,))
  14 def disable_user(request):
  15 
  16     user = request.user
  17     user.is_active = False
  18     user.save()
  19     logout(request)
  20     return Response(status=status.HTTP_200_OK)
  21
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/accounts/urls.py b/apps/accounts/urls.py
  --- a/apps/accounts/urls.py
  +++ b/apps/accounts/urls.py
  @@ -5,5 +5,6 @@
   urlpatterns = [
   
       url(r'^user/disable$', views.disable_user, name='disable_user'),
  +    url(r'^user/get_auth_token$', views.get_auth_token, name='get_auth_token'),
   
   ]
  diff --git a/apps/accounts/views.py b/apps/accounts/views.py
  --- a/apps/accounts/views.py
  +++ b/apps/accounts/views.py
  @@ -1,12 +1,18 @@
   from django.contrib.auth import logout
  +from django.contrib.auth.models import User
   
  +from rest_framework.authtoken.models import Token
   from rest_framework.response import Response
   from rest_framework import permissions, status
   from rest_framework.decorators import (api_view,
                                          authentication_classes,
  -                                       permission_classes,)
  +                                       permission_classes,
  +                                       throttle_classes,)
  +from rest_framework.throttling import UserRateThrottle
   from rest_framework_expiring_authtoken.authentication import (ExpiringTokenAuthentication,)
   
  +from .permissions import HasVerifiedEmail
  +
   
   @api_view(['POST'])
   @permission_classes((permissions.IsAuthenticated,))
  @@ -18,3 +24,24 @@
       user.save()
       logout(request)
       return Response(status=status.HTTP_200_OK)
  +
  +
  +@throttle_classes([UserRateThrottle])
  +@api_view(['GET'])
  +@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
  +@authentication_classes((ExpiringTokenAuthentication,))
  +def get_auth_token(request):
  +    try:
  +        user = User.objects.get(email=request.user.email)
  +    except User.DoesNotExist:
  +        response_data = {"error": "This User account doesn't exist."}
  +        Response(response_data, status.HTTP_404_NOT_FOUND)
  +
  +    try:
  +        token = Token.objects.get(user=user)
  +    except Token.DoesNotExist:
  +        token = Token.objects.create(user=user)
  +        token.save()
  +
  +    response_data = {"token": "{}".format(token)}
  +    return Response(response_data, status=status.HTTP_200_OK)
  
verification_info: {"golden_diff": "diff --git a/apps/accounts/urls.py b/apps/accounts/urls.py\n--- a/apps/accounts/urls.py\n+++ b/apps/accounts/urls.py\n@@ -5,5 +5,6 @@\n urlpatterns = [\n \n     url(r'^user/disable$', views.disable_user, name='disable_user'),\n+    url(r'^user/get_auth_token$', views.get_auth_token, name='get_auth_token'),\n \n ]\ndiff --git a/apps/accounts/views.py b/apps/accounts/views.py\n--- a/apps/accounts/views.py\n+++ b/apps/accounts/views.py\n@@ -1,12 +1,18 @@\n from django.contrib.auth import logout\n+from django.contrib.auth.models import User\n \n+from rest_framework.authtoken.models import Token\n from rest_framework.response import Response\n from rest_framework import permissions, status\n from rest_framework.decorators import (api_view,\n                                        authentication_classes,\n-                                       permission_classes,)\n+                                       permission_classes,\n+                                       throttle_classes,)\n+from rest_framework.throttling import UserRateThrottle\n from rest_framework_expiring_authtoken.authentication import (ExpiringTokenAuthentication,)\n \n+from .permissions import HasVerifiedEmail\n+\n \n @api_view(['POST'])\n @permission_classes((permissions.IsAuthenticated,))\n@@ -18,3 +24,24 @@\n     user.save()\n     logout(request)\n     return Response(status=status.HTTP_200_OK)\n+\n+\n+@throttle_classes([UserRateThrottle])\n+@api_view(['GET'])\n+@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))\n+@authentication_classes((ExpiringTokenAuthentication,))\n+def get_auth_token(request):\n+    try:\n+        user = User.objects.get(email=request.user.email)\n+    except User.DoesNotExist:\n+        response_data = {\"error\": \"This User account doesn't exist.\"}\n+        Response(response_data, status.HTTP_404_NOT_FOUND)\n+\n+    try:\n+        token = Token.objects.get(user=user)\n+    except Token.DoesNotExist:\n+        token = Token.objects.create(user=user)\n+        token.save()\n+\n+    response_data = {\"token\": \"{}\".format(token)}\n+    return Response(response_data, status=status.HTTP_200_OK)\n", "issue": "Add a feature to show the authentication token to the user on the MyProfile Page\n**Deliverables:**\r\n\r\n- [x] Add API endpoint to fetch or create (if doesn't exists) the token from database.\r\n\r\n- [x] Add Frontend with features to show, copy and download the token in JSON format\r\n\n", "before_files": [{"content": "from django.conf.urls import url\n\nfrom . import views\n\nurlpatterns = [\n\n    url(r'^user/disable$', views.disable_user, name='disable_user'),\n\n]\n", "path": "apps/accounts/urls.py"}, {"content": "from django.contrib.auth import logout\n\nfrom rest_framework.response import Response\nfrom rest_framework import permissions, status\nfrom rest_framework.decorators import (api_view,\n                                       authentication_classes,\n                                       permission_classes,)\nfrom rest_framework_expiring_authtoken.authentication import (ExpiringTokenAuthentication,)\n\n\n@api_view(['POST'])\n@permission_classes((permissions.IsAuthenticated,))\n@authentication_classes((ExpiringTokenAuthentication,))\ndef disable_user(request):\n\n    user = request.user\n    user.is_active = False\n    user.save()\n    logout(request)\n    return Response(status=status.HTTP_200_OK)\n", "path": "apps/accounts/views.py"}], "after_files": [{"content": "from django.conf.urls import url\n\nfrom . import views\n\nurlpatterns = [\n\n    url(r'^user/disable$', views.disable_user, name='disable_user'),\n    url(r'^user/get_auth_token$', views.get_auth_token, name='get_auth_token'),\n\n]\n", "path": "apps/accounts/urls.py"}, {"content": "from django.contrib.auth import logout\nfrom django.contrib.auth.models import User\n\nfrom rest_framework.authtoken.models import Token\nfrom rest_framework.response import Response\nfrom rest_framework import permissions, status\nfrom rest_framework.decorators import (api_view,\n                                       authentication_classes,\n                                       permission_classes,\n                                       throttle_classes,)\nfrom rest_framework.throttling import UserRateThrottle\nfrom rest_framework_expiring_authtoken.authentication import (ExpiringTokenAuthentication,)\n\nfrom .permissions import HasVerifiedEmail\n\n\n@api_view(['POST'])\n@permission_classes((permissions.IsAuthenticated,))\n@authentication_classes((ExpiringTokenAuthentication,))\ndef disable_user(request):\n\n    user = request.user\n    user.is_active = False\n    user.save()\n    logout(request)\n    return Response(status=status.HTTP_200_OK)\n\n\n@throttle_classes([UserRateThrottle])\n@api_view(['GET'])\n@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))\n@authentication_classes((ExpiringTokenAuthentication,))\ndef get_auth_token(request):\n    try:\n        user = User.objects.get(email=request.user.email)\n    except User.DoesNotExist:\n        response_data = {\"error\": \"This User account doesn't exist.\"}\n        Response(response_data, status.HTTP_404_NOT_FOUND)\n\n    try:\n        token = Token.objects.get(user=user)\n    except Token.DoesNotExist:\n        token = Token.objects.create(user=user)\n        token.save()\n\n    response_data = {\"token\": \"{}\".format(token)}\n    return Response(response_data, status=status.HTTP_200_OK)\n", "path": "apps/accounts/views.py"}]}