Invalid and/or missing SSL certificate when using Google App Engine - google-app-engine

UPDATE: Please, if anyone can help: Google is waiting for inputs and examples of this problem on their bug tracking tool. If you have reproducible steps for this issue, please share them on: https://code.google.com/p/googleappengine/issues/detail?id=10937
I'm trying to fetch data from the StackExchange API using a Google App Engine backend. As you may know, some of StackExchange's APIs are site-specific, requiring developers to run queries against every site the user is registered in.
So, here's my backend code for fetching timeline data from these sites. The feed_info_site variable holds the StackExchange site name (such as 'security', 'serverfault', etc.).
data = json.loads(urllib.urlopen("%sme/timeline?%s" %
(self.API_BASE_URL, urllib.urlencode({"pagesize": 100,
"fromdate": se_since_timestamp, "filter": "!9WWBR
(nmw", "site": feed_info_site, "access_token":
decrypt(self.API_ACCESS_TOKEN_SECRET, self.access_token), "key":
self.API_APP_KEY}))).read())
for item in data['items']:
... # code for parsing timeline items
When running this query on all sites except Stack Overflow, everything works OK. What's weird is, when the feed_info_site variable is set to 'stackoverflow', I get the following error from Google App Engine:
HTTPException: Invalid and/or missing SSL certificate for URL:
https://api.stackexchange.com/2.2/me/timeline?
filter=%219WWBR%28nmw&access_token=
<ACCESS_TOKEN_REMOVED>&fromdate=1&pagesize=100&key=
<API_KEY_REMOVED>&site=stackoverflow
Of course, if I run the same query in Safari, I get the JSON results I'm expecting from the API. So the problem really lies in Google's URLfetch service. I found several topics here on Stack Overflow related to similar HTTPS/SSL exceptions, but no accepted answer solved my problems. I tried removing cacerts.txt files. I also tried making the call with validate_certificate=False, with no success.
I think the problem is not strictly related to HTTPS/SSL. If so, how would you explain that changing a single API parameter would make the request to fail?

Wait for the next update to the app engine (scheduled one soon) then update.
Replace browserid.org/verify with another service (verifier.loogin.persona.org/verify is a good service hosted by Mozilla what could be used)
Make sure cacerts.txt doesnt exist (looks like you have sorted but just in-case :-) )
Attempt again
Good luck!
-Brendan

I was facing the same error, google has updated the app engine now, error resolved, please check the updated docs.

Related

I have got "403 Forbidden" using custom search engine on payed account

I am trying to use google search engine via python script. It was working fine at the beginning but later I have got "HTTP Error 403: Forbidden". I thing it is due to 100 requests per day limitation. But I have payed account and billing support told me that everyting is ok. Is it possible somehow to solve this problesm?
Thanks, Ilia
There are lot of reasons for which API will throw Error 403. You can find them all here : GOOGLE DOC FOR 403 Forbidden
Your 403 error might indicate that the API key you are using may have lost it's permissions, or that the quota of your API requests may have been exceeded and the new quota (The one you have when you already have a billing account) might not have been updated.
I assume you are using this API; If not, don't worry, the following advice might also help you.
You first need to see if your API key is still working or you might want to generate new ones. You can do this here. Your code should make reference to the new API Key file.
If it is not the case then you should wait a little bit until your Billing account is updated and the quota gets readjusted. You can read a bit more about how to monitor the requests to your APIs here.
You can always find more help with your particular issue if you describe a little the symptoms and your attempts or hypothesis to solve it.
At last you may find more info on the community page of the API.

Why is Google IAP putting double-digits request cookies in my headers?

I have an app running on Google app engine (Flask, python 3, flexible environment) using the Identity-Aware proxy to allow everyone in our organization (which uses GSuite) to control access. Recently we've been getting 413 errors.
When I looked at the cookies of the failing requests I expected to see one request cookie prefixed with GCP_IAAP_AUTH_TOKEN. Instead I see 11, each one slightly different. Their combined sizes put us over the 15kb header size limit indicated in the link below, causing a 413 error.
https://cloud.google.com/appengine/docs/flexible/go/how-requests-are-handled
I don't understand why there are so many cookies, or how to make them go away. Our users all use Chrome, and many but not all of them are intermittently running into this error. Those that aren't, when their cookies are inspected, show only a couple cookies with this prefix. See below for an example of what this collection of cookies looks like:
Eleven IAP cookies in a single header
Posting what ended up solving this particular instance of the problem in case something like it occurs to other people in the future.
The original IAP code for our project was written in 2018. At the time, IAP had a known issue requiring re-logging in every hour. The suggested workaround from this thread was to use a hidden iframe.
https://issuetracker.google.com/issues/69386592?pli=1
We followed that guidance, but Google fixed the underlying issue in June of 2019. Now, following that guidance causes a gradual accumulation of session cookies in the headers. Removing the no-longer-needed offending iframe code solved the problem.

Bug: 500 Internal Server Error while calling Google Static Maps API

Good afternoon.
We've recently noticed a growing number a API call failure when trying to reach your Google Static Maps API.
Issues initially seemed intermittent, but seems to happen a lot more frequently, if not: all the time.
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
Totally works locally or in a web browser
Sends out a 500 Internal Server Error when on our staging/production systems
Could that be related to authentication? To my knowledge, API keys aren't really enforced locally, but definitely checked for when application runs on a live system.
Doesn't report as an error in our Google API Console. Just as a regular successful call.
Sample URL:
https://maps.googleapis.com/maps/api/staticmap?center=38.121504,-122.590525&scale=2&visual_refresh=true&size=280x188&key=OUR_BROWSER_API_KEY&markers=icon:http://stage.hometrendsreport.com/images/mini_orange.png|shadow:false|38.121504,-122.590525&markers=icon:http://stage.hometrendsreport.com/images/mini_blue.png|shadow:false|38.121073,-122.5932|38.123742,-122.591363|38.123981,-122.590448|38.124226,-122.589497|38.118754,-122.588585|38.119648,-122.587095|38.123877,-122.587494|38.118187,-122.592065|38.118038,-122.591357&markers=icon:http://stage.hometrendsreport.com/images/mini_gray.png|shadow:false|38.118442,-122.589865|38.118442,-122.589865|38.12166,-122.602269|38.116919,-122.571937
Here's our code snippet, using ruby/paperclip:
self.picture = URI.parse(google_map_url.to_s)
return self.save
Any idea why this is happening?
Any help gladly appreciated.
Best regards,
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
When I access the link I get an "invalid API key", so the API Key may be the problem. I believe there are also much lower quota for requests to the static map API, while testing you may have exceeded your quota.

Problems using Twitter4j on GAE throws 401 just after deploy

Well, I'm having a weird error here:
I'm developing one GAE app to read some Twitter Data, and after read a lot of docs, I have it working on my test server (Running on my pc) but after deploy and test on the real (my appspot domain) it shows this message:
401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or >incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the >system clock is in sync.
message - Could not authenticate you
code - 32
I've tried to recreate my OAuthAppToken and OAuthAppTokenSecret keys, even changing the permissions to "Write, Read and Direct Messages" and even assingning one Callback URL but nothing seems to work...
I've tried using twitter4j.properties OR using setOAuthConsumer(TW_CONSUMER_KEY, TW_CONSUMER_SECRET) OR a ConfigurationBuilder whith the correct constants and I'm experimenting the same Issue.
I'm working with AppEngine 1.8.3 and Twitter4j 3.0.4
Iv'e been writing on log and the Twitter object seems to be well created... I dont understand why is working on my PC but not on the real app.
On some other post someone says that could be because it needs to use Sync clock.. but he doesn't explains where to change that property...
Did someone had a clue?
Ok, the problem was me (and Twitter.... well..... I really think it was Twitter problem for being so dark on his api messages)...
On testing server I was looking for an existing account and on the cloud I was looking for an inexistent one. So, It was my mistake. But seriously, what about Twitter saying: "Access Forbidden"? That doesn't have any sense...

Increase Per-User Limit for Google API: Saving not possible, always error message "Your input was invalid"

I've the same problem as this user:
http://productforums.google.com/forum/#!topic/analytics/mOOrYoTVWgo
"I am trying to increase the Per-User Limit from 1 requests/second/user to 10 requests/second/user for the Analytics API. I keep getting an error that says "Your input was invalid". I even tried updating without any changes and I keep getting the same error. It appears that there may be a bug with increasing Per-User Limits?"
What can I do?
I was facing the exact same issue & found a workaround. I disabled all the other API services from the "Services" menu in my Google API Console. I turned "off" every other service except the Analytics API, then managed to update the per-user limit for Analytics API. After doing this, I then went back and re-activated the other API services.
Update: Google has fixed the bug, now it works.
If you are still having this issue, limits may have changed on one of the apis you already are using. Play around with some of your higher rate services and see if kicking them down allows you to update your limits.

Resources