Reputation: 111
I am attempting to implement a GCM-enabled Android application but I am having trouble authenticating with the CCS server from my 3rd-party-server.
import sleekxmpp as xmpp
SERVER = 'gcm.googleapis.com'
PORT = 5235
USERNAME = 'my-project-number'
PASSWORD = 'my-api-key'
def main():
client = xmpp.ClientXMPP(USERNAME + '@' + SERVER, PASSWORD)
if client.connect(address=(SERVER, PORT), use_ssl=True):
print('Connection established.')
print('Authenticated =', client.authenticated)
else:
print('Connection failed.')
if __name__ == "__main__":
main()
Output:
Connection established.
Authenticated = False
Process finished with exit code 0
Not sure as to why client.authenticated
is always false when I know the credentials I have are the same ones on the project page in the Google Developer Console.
Upvotes: 4
Views: 468
Reputation: 794
Since you haven't really supplied a specific error message from the logs I will post a quick troubleshoot here. I used it myself when I had problems.
Server IP: you have correctly set the IP of your 3rd party server in the console. It's where you configure the API key, so I bet this is ok.
When you want to try out your project over xmpp you have to get it whitelisted, this is not so clear when reading the developer docs from google. Refer to this question for more explanation: Google CCS (GCM) - project not whitelisted . The link to get in line for whitelisting: https://services.google.com/fb/forms/gcm/
If the above also did not grant results you might want to check out if everything works fine using HTTP json messages, for which your project does not has to be whitelisted. Since this method has been around for some time, there are some working libraries like this one: https://bitbucket.org/sardarnl/gcm-client
Upvotes: 1