Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class API(Resource):
- # create a parser object
- parser = reqparse.RequestParser()
- # add agruments to the parser object
- parser.add_argument('account_id', type=str, required=False, help="Please define 'account_id'")
- parser.add_argument('username', type=str, required=False, help="Please define 'username'")
- parser.add_argument('password', type=str, required=False, help="Please define 'password'")
- # authenticate users
- def post(self, name):
- first_data = API.parser.parse_args()
- print("First data", first_data)
- if first_data:
- users.insert_one({i: j for i, j in first_data.items()})
- credentials = users.find_one({})
- account_id = credentials['account_id']
- username = credentials['username']
- password = credentials['password']
- if name == "allapps":
- status_code, result = authenticate_user(account_id, username, password)
- if status_code == 200:
- return {"information": result}, status_code
- return {"message": "Please enter correct credentials"}, status_code
- First data {'account_id': 'sderre456433', 'password': '5464ewsd', 'username': 'sdfsd543ry6'}
Add Comment
Please, Sign In to add comment