Using requests to automate "logging" into a server - python

I am trying to create a bot that joins the server by putting in a name and pressing a button that connects the request into the server., but in requests. The system hasn't been working as supposed to. It is supposed to POST the information in the correct places with the json.
payload = {
'idOftheInputBar': 'Username'
}
After that, I tried posting, getting, and patching but the response ended up with 404 or 200 but didn't send. How can make a request join the public server after putting in a username?

Related

What's the URL to implement a login functionality for Sleeper (fantasy football) INSIDE Reactjs app? after user is registered/logged into Reactjs app

I'm working on a multi-league fantasy football assistant, where a the user has there choice between a few platforms they can login to and import selected leagues from a list of all their avb leagues from that platform. Reactjs + Node.js frontend & Python + Django Rest backend (MySQL db)--working on just Sleeper functionality at the moment though.
I have tried a number of different ways, including trying to make a POST request to https://api.sleeper.app/v1/auth/login and I am having no luck! I keep getting a 404 status. I even tried a GET request to see what the URL returned and still nothing. If there is no exact URL, how should I go about getting user's logged in to Sleeper and get their initial info (mainly username) in order to go about my other requests?
Tried making POST requests in Postman with the https://api.sleeper.app/v1/auth/login URL using the below as my 'body' and was getting 404 status codes back.
{
"username": "my_usernam_here",
"password": "my_password_here"
}

REDIRCT_URI for a client side only python script using oauth

I would like to use the python instagram api but am struggling over the correct setting for the redirect url.
I have been able to feed the authorize url in by hand into a browser and get a
token back in the return url. I that case; I set the URI to localhost (127.0.0.1)
Whenever I do this via the api I end up with 400 returns.
What I would really appreciate is
1) a working example
2) when running via a script; what should be listening for the server's response that contains the token in its url ?
Thanks for any and all help

python how to handle http request and response

I have two questions. I am new to python and not fluent enough with all the BIF's in python.
I am developing a website database is on amazon simple db.
I am handling all database related queries and code using python scripts.
My first question is given an HTML page where the user gives his his login credentials I call in a python script using my handler javascript function send in a post request and get a response from my python script.
I can send a post request all right and get the values from sdb for validation. What I need to know is how to send in a response from my script back to my html page which could react to the information given.
My second question is how do I maintain an HTTP session using python?
My python code is given below although it shouldn't make for much since no response code is added:
form=cgi.FieldStorage()
organisationID= form['orgID'].value
username= form['username'].value
password= form['password'].value
sdb=sdbhelper.connect()
connection= sdb.get_domain('AdminTable')
itemnames=''
flag=False
for item in connection:
if (item.name==username+'$'+organisationID):
retrieved_item=connection.get_item(item.name)
if(retrieved_item['Password']==password):
flag=True
#Now Id like to respond with flag so that login validation can be done
If I am correctly getting your question what you want to do is to create a small API , Where you send some information to a webpage and get some other .
What you can do is once the user is authenticated you should return it a access key that is valid for a short time period .
One of the way to send data could be inform of JSON objects .
For example if user is authenticated then return
{
'KEY' : 'dklsfeir5rufui435uejhfjh5ewh5rf'
}
From the next request you can associate this short lived key along the url for access .For example send the next request to abc.py?key=dklsfeir5rufui435uejhfjh5ewh5rf (by get or by post ) . If the key is valid then process the request else send a json response saying error occurred .
The main advantage of using JSON is it can be easily decoded/ encoded for communication
(JSON | http://docs.python.org/2/library/json.html )
Secondly as you have generated access key you would not require any session .

Tornado authentication help

I just started using tornado and got it set up with nginx proxing tornado and php and everything is working corretly
What im trying to achieve is a notification system.
When a user does something such as send an email or update a field in the database if the other user is browsing the web he will get notified.
So using jquery ajax I will send the message and the name of the user to tornado.
I got that part working. ex:
$.ajax({url: "/send/notification", data: "data//Serialise from form , dataType: "text", type: "POST",
success: function(response) {
alert("Message From Tornado : "+response);
}, error: function(response) {
console.log("ERROR:", response)
alert("Failed");
}});
Then on Tornado get the name of the recipient
recipient = self.get_argument("recipient", None)
Now Using jquery ajax function to long poll tornado for a response.
But im completly lost on how to make tornado check if that notification is for him and if so send him data.
something like
if self.current_user == recipient:
self.write(some data);
Any help would be greatly appreciated
It's not quite that simple. You need to keep a list of waiting messages, and the users they are for. The example chat application is probably the best place to start, although it just delivers each message to everyone.
However, it shouldn't be too hard to modify. You could, for example, add a dict mapping users to waiting messages, and when the poll for new messages occurs, check if there are any messages for that user. Or you could just do a quick and dirty iteratation through all messages on every poll.

Problem with POST request from APE server module

I use Ajax Push Engine as push engine and Django for main site. I wrote the server
module which must send the request to my Django-based application when
new user join the channel by using Http module. My Django-based project runs on the local
machine on local.jjjbbb.org.
Ape.addEvent("join", function(user, channel) {
var request = new Http('http://local.jjjbbb.org/test-
this/'); // this is a my test url
request.set('method', 'POST');
request.writeData('test-message', 'Hello APE!');
request.getContent( function(result) {
Ape.log(result); // this code never work
});
});
But this code doesn't work, request doesn't receive. When I change url
to anything else (like www.google.com or localhost for example) all
works correctly and I have a result. But when I try to send request to
my application request doesn't work. This problem is only when I try
to send request from server side, when I use jQuery for sending from
client side all works correctly.
Why I cannot send POST request from server side to my domain?
Sorry, I already found my problem. APE works fine, it was a little trouble with CSRF protection in Django.

Categories

Resources