equivalent8
equivalent8

Reputation: 14227

Website Restrict Google Maps API key dynamicly via SDK

my question: Is there any Google API / SDK I can use to be able to dynamically add "HTTP referrers (web sites)" (assign domains) to maps API key ?

Background

I'm building a web-application portal that will allow anyone to create a business website and assign a custom domain to it.

On that generated website customer will have google maps map pointing to address of their business.

Customer has an option to add custom domain to their business website created by my web-application (by CNAME to the my web-application)

Desired feature is that once the domain background job will get triggered that will add that domain/host to list of restricted domains/hosts for my Google Maps Api key so that their domain will be able to read google maps on their domanin

note: I Have cron job DNS lookup validation check implemented to ensure that domain is really assigned to the domain

live example

here is website generated by customer on my web-application http://sbs-sos.sajtka.sk/ he assigned a domain and pointed CNAME http://sbs-sos.sk/

Reason why the google map works is because I manually white-listed their domain. I need to automate this

please aware portal is not fully launched so many bugs are happening

Upvotes: 0

Views: 544

Answers (1)

xomena
xomena

Reputation: 32138

The feature request to manage API keys restrictions via SDK was submitted in Google issue tracker in 2016:

https://issuetracker.google.com/issues/35829646

Currently, there are no any official SDK for that. However, the last update from Google says that they released experimental API to programmatically manage your API Keys and their restrictions.

The best way to handle thousands of authorized domains is to use an API to programmatically manage your API Keys and their restrictions, and we have recently launched a new service that allows you to do this.

This API is still in Alpha. If you are interested in becoming a Trusted Tester for this service, you can use the following form to sign up, please read the instructions carefully: https://forms.gle/qx2SMcarWCAsbWVp7

Please note that this API is not part of the Google Maps Platform. After you fill out the form, you will be contacted by the API Keys API team with instructions on how to get started, and how to receive support.

API Keys API is currently free of charge. However, please note that use of Cloud Endpoints may be subject to charges at high traffic volume. You can check the pricing sheet here: https://cloud.google.com/endpoints/pricing-and-quotas

I would suggest joining Trusted Tester program and try out this API.

I hope this helps!

Upvotes: 2

Related Questions