Android Jtwitter forgidden exception - android

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.

Related

I am getting an 403 error when I am trying to access an api through my app

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.

Huawei In App Purchase, implemented everything correctly but still getting the error : authorization format invalid

I am trying to implement Huawei in App Purchase kit to my application.
The request I am sending to the server is here:
request {"purchaseToken":"0000017343ec91821b076fd75f71103a5a85595d2dfd245d708fd6058e676f857792b83622c7fd51x434e.1.100059717","productId":"1007"}
I am following this guide here : https://developer.huawei.com/consumer/en/codelab/HMSInAppPurchase/index.html#0
I am following the same steps but
I am getting an error message from server which says :
result: {"responseCode":"6","subErrCode":"211","responseMessage":"6-211-authorization format invalid"}
Which part I might be doing wrong?
In the error you are getting, it says "authorization format invalid". This means your ignature verification data format is invalid. The possible errors might be :
The token in the request header is not encrypted in Base64 mode.
The character string APPAT is not appended before the access token for authorization. The correct access token is similar to APPAT:thisIsAppAtVaule.
for more information, please check : https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/iap-FAQ
You are facing issue in server side. Kindly go through the given link to know more about In App Purchase server side and client side.
In-App Purchase Article Develioper Forum:
Client side : https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201255229704010231&fid=0101187876626530001
Server side : https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201273064244120101&fid=0101187876626530001
In-App Purchase Github Link :
Client side: https://github.com/DTSE-India-Community/HMS-In-App-Purchase-Kit
Server side:
https://github.com/DTSE-India-Community/Huawei-In-App-Purchase-And-Push-Kit-Server_Side-Implementation

Google Play API returning error 401

I'm using gradle-play-publisher library to upload my app to Google Play, but I get error 401 Unauthorized when executing the publishing task.
My dev account at Google Play and service account at Dev Console are set up. Play API is enabled.
As I see from build logs, the first request sent is:
POST https://accounts.google.com/o/oauth2/token
I get 200 OK and the following json:
{
"access_token" : "< some value here>",
"token_type" : "Bearer",
"expires_in" : 3600
}
Then the next request is sent:
POST https://www.googleapis.com/androidpublisher/v2/applications/< my app's package name here>/edits
First of all, I noticed this header among others:
Authorization: <Not Logged>
And second, I get this error as a response
401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
Has anyone faced the same issue? Everything seems to be set up correctly, so I have no idea what went wrong. Thank you.
Your error means that
server responded with 401 (Unauthorized) status code but failed to provide a single auth challenge (WWW-Authenticate header) thus making it impossible for HttpClient to automatically recover from the authentication failure.
Check your HTTP POST request in you application which might expect
some short of credentials in the HTML form
I hope that you are already testing your rest API(url) by using POSTMAN google chrome extension.
Now,if your rest api works fine then consider about using that in your code, step by step try to figure out the following
server implementation is wrong or client side implementation wrong or url
parameters are wrong
check for <uses-permission android:name="android.permission.INTERNET" /> in your
AndroidManifest.xml

Reliability of Facebook Graph error messages

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 oAuth getting 'Received authentication challenge is null'

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.

Categories

Resources