I want to download items from a web API using Python3. The authorization method is to first submit an API key, get back a session token, then submit that token in the POST body for every subsequent request. The query parameters are embedded in the URL and results are returned in JSON.
Rather than write everything by hand in Python with urllib2, I was wondering if there is some kind of framework/library that helps make this easier? In other words, something that would automatically package the session token in the POST body and have an easy way to parse results? Or is raw Python the normal way?
Sorry for the elementary nature of this question; I don't do web programming ever.
Related
We are developing a chatbot to handle internal and external processes for a local authority. We are trying to display contact information for a particular service from our api endpoint. The HTTP request is successful and delivers, in part, exactly what we want but there's still some unnecessary noise we can't exclude.
We specifically just want the text out of the response ("Response").
Logically, it was thought all we need to do is drill down into ${dialog.api_response.content.Response} but that fails the HTTP request and ${x.content} returns successful but includes Tags, response and the fields within 1.
Is there something simple we've missed using composer to access what we're after or do we need to change the way our endpoint is responding 2? Unfortunately the MS documentation for FrwrkComp is lacking to say the very least.
n.b. The response is currently set up as a (syntactically) SSML response, this is just a test case using an existing resource.
Response in the Emulator
Snippet from FwrkComp
Turns out it was the first thing I tried just syntactically correct. For the case of the code given it was as simple as:
${dialog.api_response.content[0].Response}
I am trying to secure an SPA, now there is recommendations to use PCKE which is fine, there is also a lot of articles which suggest use post form response, however if the server returns a html form then how would i add the pcke verifier?
you don't, post form uses implicit flow so pcke isn't used
I'm setting up a website that will be mobile focused and one of the features I wan't to implement is users to be able to log an entry by just scanning a QR code.
For what I read is not really possible to make a POST request directly from a QR code, so I was thinking in two different options:
1. Make a GET request and then redirect that inside my server to a POST route in my routes.
So the URL would be something like https://example.com/user/resources/someresourceid123/logs/new and then this would create a POST request to https://example.com/user/resources/someresourceid123/logs/ and create the new entry to then send a response to the user but I'm not really sure this is the best approach or if it's possible at all.
My POST request only requires the resourceid which I should be able to get from req.params and the userid which I get from my req.user.
2. Do my logic and log the entry to my DB using the GET request to https://example.com/user/resources/someresourceid123/logs/new.
This would mean that my controller for that request will do everything needed from the GET request without having to make an additional POST request afterwards. I should be able to get both the resourceid and userid from the req object but not sure if being a GET request limits what I can do with it.
If any of those are possible, which would be the best approach?
I'd propose to go with a second option simply for the sake of performance. But you need to make sure your requests are not cached by any proxy, which is usually the case with GET requests.
I just started using Blueprism, we have a requirement to call API with OAuth 2 authentication. I'm trying to get a POC going using WebServices - Oauth 2.0 VBO to make a request like below
Request Inputs
Request Outputs
When i submit the request, i do not get any result, i see that token is populated but not the result. can anyone please point what im doing incorrectly here?
i tried directly using the HTTP VBO but no luck
I figured out what i was lacking, im unable to attach scope to the request to get the result. i also changed the way of using Web API services. i used the one from system tab and was able to attach scope for client credential auth type and use actions. once i got that i was able to get the result successfully.
I am trying to login to a website and based on the REST API guide provided, I will be able to receive some data for an application.
The two steps required for me to enact are:
1. Send a HTTP post command for authentication.
2. Send a GET command for receiving the data.
When I send the post command using python requests, i receive the required json response showing my login rights. e.g. role admin.
However, when I perform the get command after, it doesn't retrieve the data but sends an HTML form showing that I require authentication even though I have authenticated already.
Has anyone encountered this and how will I be able to solve it?
I am working on this for a customer and as a result, cannot post the actual login I am using and url and will hence replace this with my name with the code I will display.
Thanks
enter image description here
You can take a look at the session object in the requests library. It's used to keep a session across multiple requests.
https://3.python-requests.org/user/advanced/#session-objects
import requests
s = requests.Session()
s.get('http://httpbin.org/cookies/set?authcookie=123')
r = s.get('http://httpbin.org/cookies')
print(r.text)
This is a sample that uses a request session object to call a url that sets a cookie and then does another call with the same session (including the cookie). Just some basic example using http://httpbin.org/.