For our purposes, we will restrict it for a dummy website.
I will make a separate blog on restricting a key for android or iOS.
Simply choose the ‘HTTP referrers’ option as shown below:
This will give you information on how to restrict your API key on your dummy website. If you are wanting to restrict the key on a subdomain, you will have to follow the instructions from Google.
For our purposes, we will be doing it for a normal website address such as: www.mydummysite.com
Now click on the ‘Add An Item’ option under Website restrictions.
In the ‘Referrer’ box, place your website address as shown. Make sure to place it as shown when your site does not have any subdomains that the API key needs usage on.
Then click done. You can add other websites to the ‘Referrer’ box too. Make sure to follow the right website address format when you do choose that option.
Now click the ‘Restrict key’ option. We are going to link up the API restriction to our website.
Click the ‘Select APIs’ drop-down and choose the ‘YouTube API’ which would be at the bottom (the last one since we enabled it recently).
Click ‘OK’ and it will show the following:
Then click on ‘Save’ and you will be redirected to either adding another API key or you can click on the ‘Credential’ menu link on the left and it will take you to your API key info.
And there you have it. You can now use your API key on your website safely.
- Make sure you have created the API Key.
- Choose Restrict Key.
- Restrict the key according to your website domain name and any possible subdomains (if needed).
- Follow the exact process from Google’s instructions on restricting your website
- Ensure that the restricted key works on your website after adding the restriction.
If you are having trouble with your API key setup, please remember that some API’s require a billing account for it to work properly.
However, if this helped you, let me know in the comments below.