I am trying to connect to a site using the oAuth protocol, and I am getting the exception 'Received authentication challenge is null' on some devices when I attempt to make a https post. Now this was previously working in the emulator, but I now see the error there as well. I did a web search, and it seems like I would get this exception when I receive an 401 error from the site. Others said this was due to a malformed authentication header, but I am not setting a authentication header at all for this call.
This exact same code works on a number of devices, and used to work in the emulator (I cannot figure out what has changed). The person who runs the site has checked his logs, and does not see an error on his side at all. Does anyone have any idea what might be going on here?
Thanks.
I have found the problem. It turns out that if the time stamp on your oAuth call is incorrect, the server returns a 401 status error which on Android devices causes the "Received authentication challenge is null" exception to be thrown. All of the devices that were having this problem had incorrect times, and fixing the times fixed the problem.
Related
I am a bit new to android development. I was using an api form newsapi.org and every time I am getting
a some thing like this while api callSee the last line in run log
Can any body help me with this, like is there might be a problem from my end or some thing else?...Thanks in advance
The 403 Forbidden error is an HTTP status code that means that accessing the page or resource you were trying to reach is absolutely forbidden for some reason and you don't have permission to access [directory] on this server. I saw your attached image and I think maybe your api key is out dated.
The GCM API has suddenly started throwing an Unauthorized (401) error. A lot of answers suggest using Server key instead of an Android key, but we are already doing that.
Also the Allowed IPs field is left blank. The key was working until a couple of days ago it suddenly started throwing a 401 error.
We have also tried regenerating a new key, but it still throws a 401. Any help would be greatly appreciated.
Found a related thread to your issue. Maybe you had the server key configured in your Android project and was creating new Sender(SERVER_KEY) with it. Clearly the server key must be configured in the appengine project (with GCM messaging enabled). Otherwise it may still work, however there must be different quotas or something, which causes 401 after several days of using.
You can also try the answer here that suggests to whitelist the IPv6 address. If you want only IPV4, add this to your curl php init: curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );.
Check these related links:
GCM http 401 authorization error
GCM HTTP Error 401: Unauthorized
Hope this helps!
I am re-implementing an existing worklight system. We have already have a hybrid version. We have decided to re-implement the Client side in pure native. The native client seems work fine.
However, the server seems to be quite unstable - sometimes we don't get a server response after invoking an adapter, sometimes we do get. I have checked the DDMS/Android console. And a Error/Exception was found. Any comments would be appreciated!
com.worklight.common.Logger$SendLogsRequestListener(4274): Logger$SendLogsRequestListener.onFailure in Logger.java:1726 :: Failed to POST data from file /data/data/${APP_NAME}/files/analytics.log.0.send due to: HTTP response code: 500
On a successful adapter call or WLClient connection to the server, the client will attempt to automatically send logs to the server. It looks like something bad is happening on the autosend for adapters. A temporary workaround would be to disable this auto sending behavior by calling
WL.Logger.setAutoSendLogs(false)
But you can only use this call if you do not wish for logs to be sent automatically. If you do wish to have this working properly, I'd suggest opening a PMR so that it can be determined if this is an error in your application or an actual defect.
Is there a reliable way of getting access token errors from the facebook platform?
Our iOS/Android App needs to save the users Facebook session. This is fine except that authentication errors we get from Facebook seem to be inconsistent.
Essentially, if we get an error from facebook, we want to know if this requires the user to reauthenticate or if it's due to an intermittent error (i.e. they are being rate limited for some reason).
Most facebook graph errors seem to include an error code in the body of the error message text.
Some do not.
e.g
{"error":{"message":"Error validating access token: The session is invalid because the user logged out.","type":"OAuthException"}}
Does not contain an error code, so the only way to check against this error is to do a string comparison on "message". That seems a remarkably unreliable way of checking for errors.
It seems ~almost~ possible to check to see if the "type" variable in the json string indicates an "OAuthException", except that if the user is rate limited, then that will throw an OAuthException as well but it doesn't require the user to log back in, it only requires them to wait a little while and stop posting so much.
I have seen the How-To listed here: https://developers.facebook.com/blog/post/500 but that will still have the problem that my games will require users to log back into facebook if they happen to be over-enthusiastic about posting to their wall.
So, is there a reliable way of getting errors from the facebook platform?
Right now the best solution I can find is to parse the message string for error codes, and if I don't find any then reparse the string looking for specific messages (such as "Error validating access token") and then finally if I can't determine what the error is, just panic and log the user out.
Unfortunately I haven't found a great way of handling this. The best solution I've found so far is to look to see if the error is an OAuthException, compare the error message against a white list of "acceptable failures" that do not require reauthentication, but if the error does not match any error on this white list, I assume that the user has to reauthenticate with Facebook.
For reference, the only error I've found that can be whitelisted is the "user is rate limited" error. To detect this, I check to see if the error message contains the substring "(#341)", which is the error code of this error (not that this error is one of the few errors that contains an error code in the error message body).
Android I am using jTwitter
Twitter my_twiter = new Twitter("my_user_name","my_pass");
my_twiter.setStatus("hello world");
line 2 throws
winterwell.jtwitter.TwitterException$E403: Forbidden http://twitter.com/statuses/update.json (my_user_name)
what does that mean ??
One reason Twitter will return a 403 error is if you repeatedly post the same status message. That's probably what you've encountered here.
Try adding a random number to your test code, e.g.
my_twiter.setStatus("hello world "+new Random().nextInt(1000));
By the way, I see you're using the username/password login method. Twitter have announced they're switching that off - I think at the end of August. You may want to switch to OAuth. See the JTwitter homepage for details: http://www.winterwell.com/software/jtwitter.php
403 Forbidden: The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits.
Statuses over 140 characters will also cause a 403. But since you are just doing "hello world" that shouldn't be the case. The response body will contain a detailed error message.