Python Request Module throws 403 Error + SharePoint Online - python-3.x

I am currently writing a script which will pull information from sharepoint online. To do this outside the sharepoint environment. I need to get the token and Cookies (FedAuth, rtFa). Sames cookies i can get using the requests in python.
Now, If i pass the same cookies in header in my script, while fetching the List data from SP Online. it throws 403 Error. But if same cookies i use in Postman to fetch the list data. It successfully fetches the information.
Can anyone tell me what i am doing wrong?
EDIT: figured out the answer, here is the link for the same

Related

How can I connect to the google search ads 360 api via a python script?

I have to build a data pipeline which downloads reports from google search ads 360, processes them and saves them in google big query. Because we're planning on migrating this to aws, it has to be done via python script which calls the sa 360 api. I have scoured the documentation and I can't find a programmatic way to make this api call. the only thing I've found is a way to get an access token manually by running an outdated python 2.7 script (https://developers.google.com/search-ads/v2/prereqs#install-sa360api.py). This script redirects you to a sign in page which the authorized google user has to click on in order for the script to receive an access token and a refresh token.
I was hoping that once I had this refresh token, I would be able to use it programatically every time I connect, but after attempting to get a new access token using this refresh token I got a mysterious "invalid_grant" error even though I replicated the get_refresh_token request from the sa360api.py script exactly. Having read up on this "invalid_grant" error it seems there are a number of causes, but I don't think I have met any of the criteria: (https://blog.timekit.io/google-oauth-invalid-grant-nightmare-and-how-to-fix-it-9f4efaf1da35).
Any help and examples would be much appreciated.

Cannot load webpage from Postman because of javax.faces.ViewState?

I am trying to integrate a web application written by someone else with an API written by someone else. At the moment I am trying to test one of the webpages using Postman. When the webpage is loaded in a browser it works correctly. I have replicated all of the headers and body in Postman, however when I try to launch the webpage in Postman a HTTP 500 status code appears (internal server error).
I think the issue is with: javax.faces.ViewState, which is a body key/value pair. I initially do I get request to the webpage in Postman and get the viewstate:
I tried passing the value: xxxxxxxxxxxxxxxxxxxxxx;yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy in the body key/value pair, but still I get an internal server error. I have also checked that the JSESSIONID cookie is identical in the GET request and the POST request.
I have also noticed that if I access the webpage from a browser, then there is a colon instead of a semi colon in the value if that has any bearing.
Most of what I have tried so far was suggested in the answer to this question: How to programmatically send POST request to JSF page without using HTML form?
What am I doing wrong?

Using Web API using VBO No Result

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.

Unable to get data through requests from API in Python

I am new to api and a little confused with what is the cause of the issue. I am accessing api through 2 ways:
a. I open the api url through the chrome website and it displays the result.
b. When I try to access the same api through requests.get(url), I get 403 error.
Do you know if this is possible that there is security issue involved when you access through python?
I tried same code for other api links as well and they work perfectly fine except this link.
PS: I can't share the links.
It got fixed by adding headers:
requests.get(url, headers={'User-Agent':'Mozilla/5.0'})

Retrieve BLOGS_UPLOADED_IMAGES in java

I have some java code that retrieves blogs through the REST API's. I am not using the social business toolkit, but we have our own framework for that.
The application works perfectly on an on-premise connections environment and has worked on multiple versions.
However when switching to Connections Cloud, some parts stopped worked.
We get a 403 - Forbidden exception on 2 occasions:
Getting the details of a blog post: /blogs/[blog-id]/feed/entry/atom?entryid=[entry-id]
Getting images inside the blog post: /blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image file name]
I have fixed issue 1) by switching to the plublishing API: /blogs/[blog-id]/api/entries/[entry-id].
I cannot find a way to fix issue 2). I have also found 2 other image urls:
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/[file-name]
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/BLOGS_UPLOADED_IMAGES/[file-name].media
Both return:
<sp_0:error xmlns="http://incubator.apache.org/abdera" xmlns:sp_0="http://incubator.apache.org/abdera">
<code>404</code>
<message>Not Found</message>
</sp_0:error>
I want to authenticate by using Basic Authentication when possible. This does not appear to work with the given 403 urls.
My guess is that this the basic authentication header is not picked up. I have seen this before.
I used to fix this by first calling another URL that does support basic authentication and using the Ltpa cookies to authenticate the image url.
This also does not work: I do get LtpaTokens, but when I pass all the cookies to the URL, the image still does not work.
I prefer not to use OAuth of OAuth 2 at this moment. Is there any other way to fix this?
Anybody else managed to retrieve BLOGS_UPLOADED_IMAGES?
The issue is can also be reproduced in a browser.
Make sure you are not yet authenticated and the blog has posts with
images
Go to /blogs/[blog-id]/api/media
Authenticate using the popup in the browser The Atom feed now appears. This contains the images of your blog.
403 when opening:
/blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image]
404 xml when opening: /blogs/[blog-id]/api/media/* links

Resources