oauth/oauth.py
changeset 40 10a829681179
parent 29 23de98e32b3b
child 58 c56ca9e06cc8
--- a/oauth/oauth.py	Thu Mar 31 17:16:22 2016 +0200
+++ b/oauth/oauth.py	Fri Apr 01 11:43:01 2016 +0200
@@ -230,13 +230,24 @@
 @app.route('/rest/oauth/validate/<token>')
 def validate_token(token):
     database_token = Token.query.filter_by(access_token=token).first()
-    related_client = database_token.client
+    uris = ""
+    scopes = ""
+    if database_token is not None:
+        related_client = database_token.client
+        scopes = database_token.scopes
+        uris = related_client.redirect_uris
+    if database_token is not None and database_token.access_token == token:
+        validate_errors = "0"
+        error_description = ""
+    else:
+        validate_errors = "1"
+        error_description = "token not found in db?"
     return jsonify(
         access_token=token,
-        redirect_uri= related_client.redirect_uris, 
-        error=0,
-        description= "",
-        scope=database_token.scopes
+        redirect_uri= uris, 
+        errors=validate_errors,
+        description= error_description,
+        scope=scopes
     )
 
 @app.route('/ws/resource/', methods=["POST", "PUT"])