java.io.IOException: Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/sendPlease ensure that API_KEY has been replaced by the server API key, and that the device's registration token is correct (if specified).
Searched on Google with the first line of a JAVA stack trace?
We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.
Recommended solutions based on your search
Samebug tips
- Expert tip
Check if you didn't set RequestProperty Content-Type to the wrong type or if you're trying to send the wrong file to the server.
401 means "Unauthorized", so there must be something with your credentials. You need to pass the authentication to let the server know its a valid user. Check whether the authentication details are provided.
Solutions on the web
via GitHub by IgorGanapolsky
, 1 year agovia Stack Overflow by celik
, 1 year agovia Stack Overflow by Meriem.ZJ
, 5 months agovia Stack Overflow by TDeveloper
, 7 months agovia Stack Overflow by ThatGuy343
, 2 years agovia GitHub by raghzz
, 2 years agojava.io.IOException: Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/sendPlease ensure that API_KEY has been replaced by the server API key, and that the device's registration token is correct (if specified).
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at gcm.play.android.samples.com.gcmsender.GcmSender.main(GcmSender.java:82)