oauth/oauth.py
changeset 40 10a829681179
parent 29 23de98e32b3b
child 58 c56ca9e06cc8
equal deleted inserted replaced
39:5fb10e370c61 40:10a829681179
   228     return jsonify(id=user.id, displayName=user.username, ENTPersonStructRattachUAI=user.uai)
   228     return jsonify(id=user.id, displayName=user.username, ENTPersonStructRattachUAI=user.uai)
   229 
   229 
   230 @app.route('/rest/oauth/validate/<token>')
   230 @app.route('/rest/oauth/validate/<token>')
   231 def validate_token(token):
   231 def validate_token(token):
   232     database_token = Token.query.filter_by(access_token=token).first()
   232     database_token = Token.query.filter_by(access_token=token).first()
   233     related_client = database_token.client
   233     uris = ""
       
   234     scopes = ""
       
   235     if database_token is not None:
       
   236         related_client = database_token.client
       
   237         scopes = database_token.scopes
       
   238         uris = related_client.redirect_uris
       
   239     if database_token is not None and database_token.access_token == token:
       
   240         validate_errors = "0"
       
   241         error_description = ""
       
   242     else:
       
   243         validate_errors = "1"
       
   244         error_description = "token not found in db?"
   234     return jsonify(
   245     return jsonify(
   235         access_token=token,
   246         access_token=token,
   236         redirect_uri= related_client.redirect_uris, 
   247         redirect_uri= uris, 
   237         error=0,
   248         errors=validate_errors,
   238         description= "",
   249         description= error_description,
   239         scope=database_token.scopes
   250         scope=scopes
   240     )
   251     )
   241 
   252 
   242 @app.route('/ws/resource/', methods=["POST", "PUT"])
   253 @app.route('/ws/resource/', methods=["POST", "PUT"])
   243 @oauth.require_oauth()
   254 @oauth.require_oauth()
   244 def reference_resource():
   255 def reference_resource():