Login to side
#1
Hey,

maybe a little off-topic but I hope you can help me or point me in the right direction. The page I created a plugin for has changed the site completely and with this the login procedure.
The sign-in url is something like https://app.example.com/users/sign_in. I signed in with Firefox and used it's Inspect Element tool to get the POST data. The curl command I got looks like
Code:
curl 'https://app.example.com/api/v1/auth/sign_in' -H 'Content-Type: application/json' -d '{"email":"username","password":"pass"}'
Note that the url here defers from the regular login url. Also note that I stripped down the headers from the command.
The curl command returns success and what seems to be my whole account information.
Now I can do the same in python with urllib2 and get the same result as the curl command. (The url being the same as the url in the curl command.) How can I manage to get a login to the usual site, i.e. https://app.example.com/users/sign_in and then get the page I am redirected to as a result? I think I don't understand this whole thing behind json.
Code:
req = urllib2.Request("https://app.example.com/users/sign_in", json_data, headers)
>>> response = urllib2.urlopen(req)
>>> the_page = response.read()
doesn't seem to work..
Do you guys need more information?
Would be glad to get some input. Thanks!
Reply
#2
I would guess you have to do a http-post to login.

Here is an example: https://github.com/skipmodea1/plugin.vid...gs_play.py
Reply
#3
You need to show more Python code than that? Have you set proper "Content-Type" header? What is your "json_data" actual value?

BTW, I strongly recommend to use requests library instead of built-in Python facilities.
Reply
#4
(2017-04-21, 06:25)Skipmode A1 Wrote: I would guess you have to do a http-post to login.

Here is an example: https://github.com/skipmodea1/plugin.vid...gs_play.py
That was how my plugin was handling the login before the update, and while the result has code 200 now, the site I get is the sign-in site again.

(2017-04-21, 08:34)Roman_V_M Wrote: You need to show more Python code than that? Have you set proper "Content-Type" header? What is your "json_data" actual value?

BTW, I strongly recommend to use requests library instead of built-in Python facilities.
Oh yes sure. Here are the headers I used
Code:
{'Content-Type': 'application/json', 'Host': 'app.example.com', 'Referer': 'https://app.example.com/users/sign_in', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'}
and the json_data is just
Code:
{"email":"username","password":"pass"}
Reply
#5
Try this:

http://stackoverflow.com/questions/20475...l#20475712
Reply
#6
(2017-04-21, 12:51)Skipmode A1 Wrote: Try this:

http://stackoverflow.com/questions/20475...l#20475712

The history is empty
Reply

Logout Mark Read Team Forum Stats Members Help
Login to side0