'404: Not Found Error' when requesting Blogger posts from Google API - google-api

Getting an error when I attempt to retrieve a list of Blogger posts through the Google API.
Am using python requests module to make requests via plain GET urls. (Not using the Google Python Client).
>>> posts = requests.get( "https://www.googleapis.com/blogger/v3/blogs/MY-BLOG-ID/posts?key=MY-API-KEY" )
>>> posts
<Response [404]>
The same API does report successfully on a private status request, using the same blog ID and same API key:
>>> r = requests.get( "https://www.googleapis.com/blogger/v3/blogs/MY-BLOG-ID?key=MY-API-KEY" )
>>> r
<Response [200]>
The response shows the blog has posts:
>>> r.json()['posts']['totalItems']
8
I can get a list of posts using the test url provided by the Blogger API documentation, using the same API key again:
>>> tP = requests.get( "https://www.googleapis.com/blogger/v3/blogs/2399953/posts?key=MY-API-KEY" )
>>> tP.json()['items'].__len__()
10
But my own blog gives a 404 when asked for posts using the same credentials that worked fine with these other requests. The same error is reported when the request url is placed in a browser.
MY-API-KEY is the api key obtained from a project created in Google Cloud Console, within which the Blogger API is activated.
What could be going wrong here?

Related

Youtube Data Api Search Endpoint 401 Error

I'm trying to use the Youtube search endpoint, which does not seem to require an OAuth token. I've read a few tutorials and they only pass an API key. I'm getting a "Failed to load resource: the server responded with a status of 401 ()" error in my console in Chrome Dev Tools. Specifically, looking at the Network tab I get this:
I notice it says that there is an error: "invalid_token" but I pass the api key so they must be talking about the OAuth token? I'm confused because it shouldn't need one, especially because I'm just doing a query for public data. Even the Try This API portion of the endpoint documentation does not need one. Most importantly, my call in Postman works and just pasting the endpoint in my browser directly works. Why doesn't it work? This is using an axios call from a ReactJS frontend.
const apiKey = 'MY_API_KEY';
const url = 'https://www.googleapis.com/youtube/v3/search';
const response = await axios.get(url, {
params: {
part: 'snippet',
maxResults: 5,
q: songName,
key: apiKey
}
});
What was happening was that I was using axios.defaults.headers.common['Authorization'] =Bearer ${params.access_token}; in other calls for another API. This causes default everything to have this access token! So what I did for now is delete axios.defaults.headers.common["Authorization"]; -- the solution is pretty obvious, just make sure you have no extra headers because Search is not a OAuth endpoint!

Prestashop / Google API error 400 invalid_request

I tried to connect the Google Analytics API to my Prestashop 1.6.1.11.
I created and install the Google Analytics, then configure the API Google Anlytics in v3.0 mode ( with OAuth 2.0 ), but each time I put the parameters (ID Client, secret key and Profile ), Google Analytics API redirect me to a 400 error with this message :
Error: invalid_request /
Invalid parameter value for redirect_uri: Missing scheme: modules/gapi/oauth2callback.php
I don't understand because when I create the API identification, I put the redirect URI like that :
http://www.websitename.com/modules/gapi/ouath2callback.php
And same for https, but still doesn't work
Did I miss something ? Thanks a lot in advance
It looks like you are using a relative URI "modules/gapi/oauth2callback.php". It needs to be the full, absolute URI, character for character identical to the URI you defined in the API Console, eg. "https://www.websitename.com/modules/gapi/ouath2callback.php". Also, don't use http for redirect URI. It's only a matter of time before plain text URLs are disabled for security reasons.

how to import google contacts in laravel 5.2

I'm working with laravel and I have done login with Google in laravel using socialite. Now I'm trying to get google contacts and I'm using Artdarek\OAuth for this. But I'm getting an error
TokenResponseException in StreamClient.php line 68: Failed to request resource. HTTP Code: HTTP/1.1 400 Bad Request
here is error screen shot
I also tried many links, but I don’t know what’s problem with my code.

Picasa Web Albums REST API: 404 Unknown User issue

I'm trying to get the list of albums as it is written here: https://developers.google.com/picasa-web/docs/1.0/developers_guide_protocol#ListPhotos
GET https://picasaweb.google.com/data/feed/api/user/default
Authorization: Bearer MY_ACCESS_TOKEN_HERE
So, the problem is that I get "404 Unknown user" responce. Strange thing but when I make the same request with the same access token from another PC, I get the correct responce (200 OK and list of albums).
I didn't google anything useful except the similar issue which was on API for Python (like here: AuthSub: (404, 'Not Found', 'Unknown user.')). Did anyone face the same issue?
So, the problem was that Google Photos server handles the requests incorrectly, if these requests contain some wrong Cookie headers.
I say "incorrectly" because other Google APIs (like Drive, Contacts, etc.) didn't have this issue.
So, all that I had to do is to add flag INTERNET_FLAG_NO_COOKIES in InternetOpenUrl function:
InternetOpenUrl(NetHandle, PChar(Url), PChar(Header), Length(Header), INTERNET_FLAG_RELOAD or INTERNET_FLAG_NO_COOKIES, 0);
After that sending HTTP requests using InternetOpenUrl with the flag won't return this error anymore.

Full text search using Google Sites API gives 500 internal server error

I tried incorporating the full text search using the Google Sites API (via a service account) but to no effect. I also tried it on the Google Oauth playground, but I get 500 Internal server error in both the cases.
I am using https://sites.google.com/feeds/content/domainName/siteName?q=test as the URL.
However, I do get a 200 OK when I fire https://sites.google.com/feeds/content/domainName/siteName (without a query string) in the Google Oauth playground.
Please guide me if I am doing anything wrong.
Thanks

Resources