Managing API keys for GCM without Firebase? - android

I have an Android app with push notifications send by GCM. I set this up a few years ago. All works fine.
Now i want to manage my API keys but the Google Play Developer Console is not showing the API keys anymore, like they use to do. They always link to the new Firebase API.
I tried https://console.cloud.google.com/apis/credentials but the new API keys won't be accepted by Google and the old one doesn't show up there. That's maybe because I can't link it to my Android app.
Where can I still manage my GCM API keys? I want to create a new one but I don't want to migrate my project to Firebase. Is this still possible?

Go to Android Start and click Get a Configuration File. There you'll be able to generate GCM API keys. The same goes if you're using iOS.

If you are like me and gave in to FCM, you can still use the GCM project identity: its under console, FCM settings and contains the server key and identity.

Visit this link and follow the steps
https://developers.google.com/mobile/add?platform=android
Download the google-service.json file, it contains the keys you need

Related

Android Firebase PERMISSION_DENIED reason API_KEY_SERVICE_BLOCKED

I ran into such a problem, when I tried to initialize firebase and get the FCM token, I get this error, who faced it? What could be the reason? A month ago, everything worked, after that nothing was changed in google-services.json file, firebase flow in project, or in google console.
API key permissions added
In our case, this happened when we added a new Firebase library to our project (Performance Monitoring). Our API key is restricted to only allow certain APIs to work, as suggested by Google.
Log in to the Google Cloud Console, and make sure you're allowing the API to work with your restricted key. In this specific case, you need to allow the Firebase Installations API.
Once I added that and waited about 10 minutes, this error stopped and the Firebase tools are working as expected with our app.
I fixed same error while adding push notifications into iOS project:
Fixed on Google Cloud console -> APIs & Services -> Credentials
then CLICK on the API Key you are using for the app having problems
Scroll to the API restrictions section
expand the combo box and select Firebase Cloud Messaging API and Firebase Installations API hit OK after selecting both and SAVE this.
REMEMBER: Wait 5 to 10 minutes to test this working, so be patient and grab a coffee before testing again :)
The problem was on key, idk why, but when I set new key, all ok.
20.05.2022 Better to use Android apps restrictions now.

Firebase with dynamic applicationId

I am maintaining a website where people can customize an Android application and download as an apk file.
I need to implement push notifications. I had it implemented in Google Cloud Messaging before. But I am moving to Firebase now.
The problem is that Firebase is configured with specific application ids through google-services.json configuration file. But I need it to run with automatically generated application ids.
I have already tried to change the id in the configuration file. It compiles, but notifications are not delivered.
Please, can anyone tell me if there is a way to make it work?
Edit:
I don't see how my question is related to an Android Datepicker question with nothing to do with Firebase.
There is only one way, you need always create new android app per every unique app id in firebase console. Then download and build new app instance with generated 'json'. Unfortunately, firebase does not provide any API for automatization this, and you have to do it manually every time.

Google Developers: You have exceeded the maximum number of projects that you can create

I have ten Android apps that support Push Notification with OneSignal.
I always followed this manual: OneSignal manual: Generate Google Server API Key.
I always created a new project as in the manual described.
Now I wanted an eleventh app to be able to get Push Notifications. But when following the manual I'm getting:
You have exceeded the maximum number of projects that you can create.
Try deleting a few projects in the Google Developers Console.
at Add Project in Google Developer Console.
What can I do? Won't I able to make more apps be able to receive Push Notifications?
I hope anybody can help me because it's a time-sensitive project.
You can re-use the same project number and server key across multiple android apps without any issues. This is the best way to support notifications for more than 10 apps.
You can make a request here: support.google.com/code/contact/project_quota_increase
I got a positive Quota Granted-response within 30 minutes although I'm not using any paid services.

How to get the Browser Key for GCM as per the latest Developer Console?

I want to get the GCM Browser Key in the Developer Console, but the latest Developer Console doesn'tshow the Browser Key selection.
If I click Credentials, it doesn't show anything apart from one single key. I don't know what is the procedure to get the Browser key.
If anyone knows let solve my problem. Thanks in Advance.
You need to go to Google Developer Console and follow this steps:
Create Project
Enable Library
Create Credential (*)
(*) when u create credential, click on Restrict Key and add your specific Key restriction.
Update: There is now a visible note in the GCM docs saying:
Starting from Sept. 2016 new server key can only be created in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
Update: It seems that using the Server Keys from the Firebase Console is the sure thing solution.
If you are just starting to use GCM, instead of creating a project in the Google Developers Console, do it in the Firebase Console. After creating the project, simply use the auto-generated Server Key. Here are the steps where to find the Server Key:
Go to your Firebase Console and click on CREATE NEW PROJECT.
Fill in your desired Project Name and select your Country. After this, the new Project should be active.
Then on left-side panel, click on the gear button and select Project Settings.
Then go to the Cloud-Messaging Tab.
For old GCM projects, you can simply Import the project to the Firebase Console:
Go to your Firebase Console and click on IMPORT PROJECT.
Select the project you want to import and your country.
Click on ADD FIREBASE. After this, the new Project should be active.
Then on left-side panel, click on the gear button and select Project Settings.
Then go to the Cloud-Messaging Tab.
Basing from the image, you've already generated an API Key. But gonna include the steps for visibility:
Go to your Google Developers Console
On the left-pane, click on Credentials
Under the Credentials Tab, Click on Create Credentials
Select API Key
With that, the API Key is already available. However, it will default as a No Restriction key. You may click on Restrict Key to add the restriction corresponding to what you need the API Key for.
I'm not entirely sure, but for a Browser Key, I think you would need to set the HTTP referrers (web sites) restriction. Since basing from the other restrictions:
IP addresses (web servers, cron jobs, etc.) = Server Key
Android apps = Android Key
iOS apps = iOS Key
You may try the API Key generated without any restrictions, however, it is highly encouraged for you to add the corresponding restriction as a security measure against unauthorized usage and quota theft.

This IP, site or mobile application is not authorized to use this API key - Android

I have a problem with connection with Google maps API V2 and Android. I' ve enabled services:
Google Maps Android API v2
Places API
Also I've added sha1 fingerprint.
But I still get this message: This IP, site or mobile application is not authorized to use this API key
I'm calling service from Android. Do you know where might be the problem, cause I don't know where to search.
You must be creating a browser key instead of an android key. I faced similar problem when I accidentely created an android key for Google Cloud Messaging instead of a server key. Please check which key is required for your purpose. For google maps v2 you need android key and for google places api you need a server key(searched google but not so sure on this one never used it). So basically you need two keys.
Update:
You need server key for places api.
Refer this tutorial.
http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/
Step 1- Go to code.google.com/apis/console/?noredirect
Step 2- Create a new project
Step 3- Go to services and choose Places API, turn it on. This will ask your organization name and url.Fill them and click Ok.
Step 4- Now go to API Access and there will be your API Key. You don't have to click on Create new key. This will be your browser apps key which you can use in your Android Apps.
This solution worked for me perfectly.
If generating an Android App, the "Server" IP address could be any IP of any phone on any network. What do I write in the "Accept requests from these server IP addresses" box in order to have any IP address accepted?
Edit - Apologies. Apparently just leave it blank...
I just had this issue the other day, it is not actually an issue with this library.
First, make sure you're using a server API key, not an Android/iOS key (if you're doing mobile development). See this stackoverflow post: Google Places API request denied for Android autocomplete, even with the right api key . The TL;DR version of that link is that Google Places API doesn't support the Android/iOS key option, only the server option.
Second, and this goes without saying, make sure you're passing the key to the GooglePlaces instance.
Lastly, if you're restricting use of the API key by IP make sure your request is coming from an allowed address.
You don't need to create a key for using Google place API, instead just use "Key for browser apps (with referers)". But if you want to use Google Map API, you need to generate a Android Key, and you could find instruction here :https://developers.google.com/maps/documentation/android/start.
Good luck.
I got this problem too. but I SOLVED this issue only using something tricky. Go to your google console and create new key which is browser key, then let the column empty and save. you can use the key that has been created in you mobile apps now.
GOOD LUCK! *Unfortunately I can't post an image to this answer
Change your API key, you may use Android key in the URL. For to specify Key in the URL you need to get WEBSERVICE key.

Categories

Resources