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!
Related
I have an ionic app that when I run that on iOS then it works perfectly fine but when I run that on Android I get this error
Http failure response for (unknown url): 0 Unknown Error
Any reason I am getting this one? I have allowed CORS on server side as it is working on iOS devices.
Any help?
EDIT
This is what I have in my app.js file
const cors = require('cors');
And then I simply use it with default options.
app.use(cors());
If you are using localhost, change it to the IP address of the localhost. Android doesn't seems to support it where iOS do.
Try actual host name in case it didn't work too.
First you dont need CORS to call API from your android device.
Second probably your server is not accepting your request. If you are using Cloud then your server must accept request from any IP. There must be a option for allow IP address, place there from 0.0.0.1 to 254.254.254.254 so that each and every user can call your API.
Third you need to allow origin from your config.xml and also in header for CROS request. Check your API header and config file.
And fourth If your service is running under http then it will also could be the problem. Secure your service by adding SSL certificate. This could fix your problem.
We had experienced the same Error several times in our App. In our case it was a problem with the headers of the request and also a CORS problem on the serverside.
Are you able to reproduce this error in the browser if you emulate a android device? Then you could compare them with the headers of the iOS request.
Or you can try to log the incoming requests on the server-side to see if the requests reach the server and what headers are set.
Hope my ideas help :)
The solution is to add NODE_TLS_REJECT_UNAUTHORIZED=0 to your environment to disable the SSL verification in Node.js.
Note : You should only set this in development, Don't do this in production
EDIT
In that case it indicates that CORS has not been properly setup on your server. Go through the issue here
I have a little problem with Volley. I'm trying to get the response from some url which is fully working on mobile browser.
Meanwhile in my application I'm getting an error:
ERROR: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Signature uses an insecure hash function
Is there a way to solve it in an application or should I contact with my backend provider?
I did a little digging and found that:
Google is now blacklisting weak hash functions in SSL certs and throwing exceptions when trying to communicate with the problem server. Whereas before, it was silently ignored.
Source
With that in mind, you could try doing this to teach HttpsURLConnection to trust a specific set of CAs.
But in the end, I believe that its your backend providers fault in providing a insecure hash function. So, before trying a huge workaround maybe contacting your backend provider would be the easier way out.
Hope it helps.
I'm trying to implement the sample Twitter Digit app available on Github.
https://github.com/twitter/digits-android
But after following all the steps and populating every known place with API key and API secret.
My code is same I've just populated the properties file.
I'm getting: Digitsīš HTTP Error: 403 Forbidden, API Error: 239, User Message: Try Again
Can anyone tell where the mistake is ?
The project will not work when copied as-is. You need to replace the consumer key and secret provided in the example project with your own. You can generate your own consumer key and secret via Fabric web portal.
#stack5: I have written this answer after reading the comments. I found that you've already received your answer. I'm writing this here so that anybody else facing similar issue would get benefited. Please accept this answer for the community.
Can't authenticate with Yammer.
I've tried to use socialauth library but without any success.
public void onError(SocialAuthError socialAuthError)
Error log:
org.brickred.socialauth.exception.SocialAuthConfigurationException: Problem in getting Access Token. Application key or Secret key may be wrong.The server running the application should be same that was registered to get the keys.
Could not connect using SocialAuth
I've checked the keys again and both consumer_key and consumer_secret are right.
Even got the issue registered, but seems the project is not supported anymore.
https://code.google.com/p/socialauth/issues/detail?id=385&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Modified
With my own authentication I could get an access token, but could not make any REST-API call. Just getting an error "Unauthorized" (401) all the time.
HTTP params are fine according to docs, got all the cookies, but can't use REST-API.
Any ideas?
Fixed. The problem was in wrong headers placement. I've been setting headers to response handler for loopj async http client, with the method handler.setRequestHeaders(...);, but the right way is to add headers to client - client.addHeader("Authorization", "Bearer " + access_token);
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.