Problems using Twitter4j on GAE throws 401 just after deploy - google-app-engine

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...

Related

Java IOException during API request to Stripe (APIConnectionException)

The specific action we are trying to performe is to create a charge request with Stripe:
Charge charge = Charge.create(params);
Using Stripe's Java implementation (version 5.35.1) we encounter a APIConnectionException when running the application on the deployed App Engine server. Interestingly, the issue does not occur using App Engine's local dev server.
We contacted Stripe and they said everything is fine on their side. They explained that "this error indicates that your server is not able to contact our API and that it ends up timing out waiting for an answer. Usually, this is due to something misconfigured on your server such as a DNS not redirecting to Stripe properly."
We were wondering if there are some configuration settings on App Engine which cause the problem. However, since there is no specific error message we cound not figure out what might cause the connection problem.
Similar problems which did not provide enough help to resolve this issue: https://issuetracker.google.com/35901039
Thanks for your help!
The problem seems to have solved itself. It occured for a couple of days and since a few hours the exact same code is working fine. Just like in https://issuetracker.google.com/issues/35901039 the problem is suddenly gone for some reason.

Openshift: Uploading File not possible / Sending emails not possible

I have a small web project where I use openshift as a service for a test system.
Now I got 2 problems:
1) I have a form in which a user shall upload a picture. For that I use multipartfile. But the file upload just doesn't work, while it does locally under dev.
So now I ask myself if I need to configure something on the server. But I couldn't find out what (and why).
2) I am sending emails after a certain action. Which again runs perfectly fine under development, but not using my test system on openshift. If I remember correctly it was a 415 error, I have to repeat the test at home to look it up.
I can't give more information right now as I'm not yet home, but I don't think that much code is needed as it all works fine testing it locally.
I post this question rather for a quick answer like "uuh yeah, for openshift applications you need to configure it first for doing those things: here and there, make this and that and read here" which I oversaw.
I hope someone can give me some hints, I don't get why it all works locally but not on a test system.
Quick Answer:
Make sure your file uploads are being sent to your $OPENSHIFT_DATA_DIR and for email check out this post https://www.openshift.com/forums/openshift/send-mail-through-openshift-using-gmail or use something like SendGrid which is free in the OpenShift Marketplace.
If those don't help, posting some application logs will be really helpful

Invalid and/or missing SSL certificate when using 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.

How to resolve the "Unusual traffic" error with calls from appengine to gdata

App-engine CAPTCHA code
Googles GData is asking Google-app-engine for a CAPTCHA code.
How to enter a code OR reset things?
Error message
All has been working fine for about 1 year, but then I got this "Unusual traffic" error yesterday.
My logs show a link to the page: "Unusual traffic from your computer network"
i.e. support.google.com/websearch/answer/86640
What is also strange, almost all the errors are calls that "Write" to Gdata, most "Reads" work just fine.
The call to:
com.google.gdata.client.GoogleService.insert
causes the error:
com.google.gdata.util.ServiceException
I am using the gdata style spreadsheet API
Also the load has been low, load several times the current load has worked fine in the past.
Issue
I created an issue here: https://code.google.com/p/gdata-issues/issues/detail?id=6237
Took a few hours - but this worked:
a) Added the App-Engine IP addresses to support.google.com/websearch/contact/ban
b) Creating the issue in the GData issue tracker may have helped.
Is hard to be sure which of these resolved the problem, but is now working again.

Google App Engine + Jersey + IntelliJ Idea

Okay so I'm having some annoying issue here. I am clearly missing something, and already been frustrating myself with this for the last 4-5 hours.
I cannot seem to be able to create a simple GAE+Jersey up and running with IntelliJ.
The frustrating part is that I do not get any errors, just that the REST service is not present after deployment.
I've tried out a few basic stuff, basically everything you can find on Google (and here).
After some frustration I've downloaded this project: https://github.com/BluerockInteractive/GAE-Jersey-Guice-Sample
Just cause this will list out the available servers, plus the deeper logging level.
Now here's the output of the AppEngine startup:
https://docs.google.com/open?id=0B42XvjSlpDCtTTdwQl9MSTBlQ0U
So my problem: The AppEngine is up and running. If I create a basic servlet everyting works fine. However, I cannot get Jersey to work. In every form I could try it always throws an
HTTP ERROR 404
Problem accessing /jerseyguicesample. Reason:
NOT_FOUND
Powered by Jetty://
Any ideas, what I could be missing here?
Here's an image of the IDE and the artifact settings: http://img51.imageshack.us/img51/7913/20120428124133.png
Thanks, :D
This example has REST handlers mapped to /rest/test, /rest/players/{name}/xml, /rest/players/{name}/json and /rest/hello.
What (and where) did you map /jerseyguicesample to?

Resources