How to get api key from google for push notification

31,192

Solution 1

You used an old tutorial that describes the old UI of Google APIs. In the new UI you need to do the following (source):

To obtain an API key:

1. In the sidebar on the left, select APIs & auth > Registered apps.
2. Click Register app.
3. In the Name field, type your app's name.
4. Click Android > Accessing APIs directly from Android.
5. Under Android identification, type the package name for your app.
6. Enter an SHA1 fingerprint. To get this value, follow the instructions in the 
   console help.
7. Click Register.
8. In the new page, open the Android Key section and copy the API key. You will
   need the API key later on to perform authentication in your application server.

Note: If you need to rotate the key, click the "recycle key" icon. A new key will be created. If you think the key has been compromised and you want to delete it immediately, you can accomplish this by deleting the app from the console. Then create a new entry for the app with the same SHA1 and package name.

To get the SHA1 fingerprint in step 6 you can use the command:

keytool -exportcert -alias androiddebugkey -keystore C:\Users\myusername\.android\debug.keystore -list -v

(and enter the default password android at the prompt)

Solution 2

You can generate api key by visiting https://cloud.google.com/console. You need to activate api for Google Cloud Messaging Service.

Also there is provision for limiting ip addresses to connect to your api. Your ip address is provided by default. You may need to remove that to use GCM using above tutorial.

For more help: check this

Solution 3

Try to visit this link without redirecting to new cloud GCM. This link will redirect to new google could but you need to click go back option to see API access menu. You will see the Message like Welcome to the new Google Developers Console! Prefer the old console? Go back | Dismiss.

Share:
31,192
Sandesh Sharma
Author by

Sandesh Sharma

Updated on December 20, 2020

Comments

  • Sandesh Sharma
    Sandesh Sharma over 3 years

    I have followed this tutorial for android push notification. I am not getting services-> api access menu and api key. How to get API key? The UI is not showing API key, I have created the project too.