Ich habe eine Sicht, sendet es Anfragen an http://127.0.0.1:80/o/token/
Ich möchte wissen, kann ich direkt aufrufen, die Ansicht /o/token/
und erhalten Sie das Ergebnis?
und müssen nicht requests
importierenDjango View Anruf eine andere Ansicht ohne Verwendung von Anfragen
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
Mögliche Duplikat (http://stackoverflow.com/questions/4808329/can-i-call-a -view-from-interest-another-view) – rnevius
Mein Problem ist das '' ''/o/token/'' '' stammt von '' '' 'django-oauth-toolkit'''', ich weiß nicht welche Ansicht ist der Einstiegspunkt von '' ''/o/token/'' '' – user2492364