0

I have a view, It will send requests to http://127.0.0.1:80/o/token/ I want to know can I directly call the view /o/token/ and get the result ?
And do not need to import requests to send it

class GetAccessToken(APIView):
    def post(self, request, *args, **kwargs):
        msg ={}
        return Response(msg, status=status.HTTP_200_OK)

    def get_access_token(self, username, password, client_id, client_secret, scope="read write"):
        url = "http://127.0.0.1:80/o/token/"
        payload = {
            'grant_type': 'password',
            'username': username,
            'password': password,
            'scope': scope
        }
        auth = HTTPBasicAuth(client_id, client_secret)
        try:
            response = requests.post(url, auth=auth, data=payload, verify=False, timeout=TIMEOUT)
        except Exception as err:
            print err
user2492364
  • 6,543
  • 22
  • 77
  • 147
  • Possible duplicate of [Can I call a view from within another view?](http://stackoverflow.com/questions/4808329/can-i-call-a-view-from-within-another-view) – rnevius Mar 22 '16 at 02:21
  • My problem is the ````/o/token/```` is from ````django-oauth-toolkit````, I don't know which view is the entrypoint of ````/o/token/```` – user2492364 Mar 22 '16 at 02:51

0 Answers0