Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Token and auth-token
#1
Hey all.
I have problem which i dont quite understand how to go about from here.
I use request library to sign-in to website and I believe im doing that right. I make a post request to /sign-in page and response to the POST request is following

b'{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjEuNTYzOTkyOTMzRTksImFwaV90b2tlbiI6ImFmYmRmZGRmMmVmMDRjYTE4NmUxZmQ2ZWU5MWM3MmE4IiwiZW1haWwiOiJwY2FicmVyb0BnbWFpbC5jb20iLCJ1dWlkIjoiNDdkYjEzYTMtY2ZkYy00NmRmLWE3OTgtYmUzMjI1MDcxYThiIn0.VQdYwBWlEkqewFQd72K2BA4Zd9aP6mQ_42uYsDgx9Ao","auth_token":"CNxnJqAuUPeeH12TB3BEaE1lU1LR4+8gkaQQjDGRoxkJ3ApQrgNXGAMwu5t8TvevBnjHp31XLNQvtonJEaJUtQ=="}'
I basically expecting some html back if the login was successful. But instead I get these token. What do I do with these token from here. My code looks like this.

with requests.Session() as s:
    url = "https://app.nutmeg.com/auth/users/sign_in"
    url2 = "https://app.nutmeg.com/client"
    r = s.get(url, headers=headers)
    soup = BeautifulSoup(r.content, 'html5lib')
    login_data['authenticity_token'] = soup.find('input', attrs={'name': 'authenticity_token'})['value']
    r1 = s.post(url, data=login_data, headers=headers)
    r2 = s.get(url2, headers=headers)
    print(r2.content)
any help would be much appreciated

Thanks

Just to add more information. Im trying to login to nutmeg account.
https://app.nutmeg.com/auth/users/sign_in
Reply
#2
Probably the site you are parsing is a kind of SPA application. This kind of sites don't return HTML as a response, they work over AJAX and receive only JSON.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  passing token to requests alejandroot 4 3,080 Mar-12-2021, 04:49 PM
Last Post: alejandroot
Photo [Solved] How do I position 'token' in JavaScript in search box? cheers100 1 1,865 Nov-21-2020, 01:23 PM
Last Post: cheers100
  The CSRF session token is missing. randiaz 0 2,995 Jul-31-2020, 08:45 PM
Last Post: randiaz
  Google calendar pthon flask auth Kireta 0 2,046 Sep-16-2019, 04:50 PM
Last Post: Kireta
  Getting csrf token to log in spartanvfl 4 24,164 Aug-08-2019, 08:19 PM
Last Post: NSearch
  Flask tutorial errors in jinja, auth undefined Ecniv 2 2,451 May-03-2019, 02:04 PM
Last Post: Ecniv
  Problem enabling http auth in a route nikos 2 2,738 Mar-02-2019, 01:13 PM
Last Post: nikos
  Python /Flask Login with LDAP Auth pythonnubie 4 8,532 Apr-16-2018, 03:14 PM
Last Post: nilamo
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 4,111 Nov-15-2017, 12:29 PM
Last Post: zoidberg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020