request_token issue

Kamalv
Good Morning @sujith @rakeshr and all,

On successful authentication trying to capture request_token from redirect url (https://sampleengine.herokuapp.com/get-request-token) but always getting 404 error. Tried to handle 404 but nothing saved as request token. (tried to save request_token in req_token in below code and print "request_token")

Python code:
@app.route('/get-request-token', methods=['GET'])
@app.errorhandler(404)
def get_request_token(e1):
try:
req_token = request.args.get('request_token')
print('request_token', req_token)
return "Success"
except Exception as e:
print(e)
return "Fail"

log:
2021-09-27T05:18:13.000000+00:00 app[api]: Build succeeded
2021-09-27T05:18:31.184906+00:00 heroku[router]: at=info method=GET path="/get-request-token?action=login&type=login&status=success&request_token=HeO4Mxgschh5bIX7DS0t4cbiQe7Bd792" host=optiwinsengine.herokuapp.com request_id=a1ba9779-9ae2-4021-bd09-f9517ebcda85 fwd="49.37.164.238" dyno=web.1 connect=0ms service=1ms status=404 bytes=393 protocol=https
2021-09-27T05:18:31.185114+00:00 app[web.1]: 10.1.8.51 - - [27/Sep/2021:05:18:31 +0000] "GET /get-request-token?action=login&type=login&status=success&request_token=HeO4Mxgschh5bIX7DS0t4cbiQe7Bd792 HTTP/1.1" 404 232 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"

Tagged:
  • sujith
    We just redirect to the endpoint specified in the developers console. The request token will be part of the url and not really in the data.
    It will be a query param on that endpoint, if you are doing some redirect then make sure you pass on the query params.
  • Kamalv
    Thanks for the response @sujith. I tried to capture from query parameters as well but nothing captured.

    def get_request_token():
    a = request.args.get('request_token')
    print('request_token', a)
    return "Success"

    Not sure if i'm missing anything, my intention is to save reruest_token. Since most of the users doing the same you might have come across this situation. If you correct/share piece of code/suggest missine piece will be appriciated
  • rakeshr
    [27/Sep/2021:05:18:31 +0000] "GET /get-request-token?action=login&type=login&status=success&request_token=HeO4Mxgschh5bIX7DS0t4cbiQe7Bd792
    Your logs shows request_token query param is added fine.
    a = request.args.get('request_token')
    Above statement is fine too to extract request_token from query string. So, my guess is, it has something to do with your heroku setup. Can you test the same flask app locally, if it's printing request_token fine?
    my intention is to save request_token.
    You should immediately use request_token to generate access_token and save the access_token to make all future requests. You can go through this flask app example to understand more about this.
  • Kamalv
    Thanks for the suggestions @rakeshr, issue with heroku, fixed it.
This discussion has been closed.