2020. 2. 18. 06:02ㆍ카테고리 없음
This guide shows how to create API keys, and how to set upAPI key restrictions, for GCP applications. To learn more about authenticatingto a GCP API, see. Forinformation about setting up API keys for Google Maps, see the. Note: Do not use API keys for local or production applications, except in thespecific cases described below. For almost all cases, you should use.API keys are a simple encrypted stringthat can be used when calling certain APIs that don't need to access privateuser data. API keys are useful in clients such as browser and mobileapplications that don't have a backend server.
Google Docs Url Parameters
The API key is used to track APIrequests associated with your project for quota and billing.API keys have important limitations, such as:.A limited number of GCP services allow access using only anAPI key:.API keys do not identify the user or the application making the API request,so you can't restrict access to specific users or service accounts.It is easier for others to discover and use your API key.Because of this we recommend. However, there are limitedcases where API keys are more appropriate. For example, if you're developing amobile application that needs to use the Google Cloud Translation API, butdoesn't otherwise need a backend server, API keys are the simplest way toauthenticate to that API. In most cases, we recommend having your applicationcommunicate to a backend server that handles authenticating to, and calling,Google Cloud Platform services.
Creating an API keyTo create an API key, your account must be granted the primitive Editor role( roles/editor) on the current project. For more information, see.To create an API key:.Navigate to thepanel in GCP Console.Select Create credentials, then select API key from thedropdown menu.Click the Create button. The API key created dialog box displaysyour newly created key.You might want to copy your key and keep it secure. Unless you are using atesting key that you intend to delete later, add. Using an API keyPass the API key into a REST API call as a query parameter with thefollowing format. Replace APIKEY with your API key, key= APIKEYFor example, to pass an API key for a Cloud Natural Language API requestfor: POST APIKEY Securing an API keyWhen you use API keys in your applications, take care to keep them secure.Publicly exposing your credentials can result in your account being compromised,which could lead to unexpected charges on your account.
To help keep your APIkeys secure, follow these best practices:.Do not embed API keys directly in code. API keys that are embedded in codecan be accidentally exposed to the public. For example, you may forget to removethe keys from code that you share.
Instead of embedding your API keys in yourapplications, store them in environment variables or in files outside of yourapplication's source tree.Do not store API keys in files inside your application's source tree. If youstore API keys in files, keep the files outside your application's source treeto help ensure your keys do not end up in your source code control system.This is particularly important if you use a public source code managementsystem such as GitHub.Set up. By adding restrictions, you can reduce theimpact of a compromised API key.Delete unneeded API keys to minimize exposure to attacks.Regenerate your API keys periodically. You can regenerate API keys from thebyclicking Regenerate key for each key. Then, update your applications to usethe newly-generated keys. Your old keys will continue to work for 24 hoursafter you generate replacement keys.Review your code before publicly releasing it.
Ensure that your code does notcontain API keys or any other private information before you make your codepublicly available.Adding restrictions to API keysAn API key is unrestricted by default. Unrestricted keys are insecure becausethey can be viewed publicly, such as from within a browser, or they can beaccessed on a device where the key resides.For production applications, set both application and API restrictions.To add API key restrictions:.Navigate to thepanel in GCP Console.Select the name of an existing API key. The restrictions section appears atthe bottom of the page.Application restrictionsApplication restrictions specify which web sites, IP addresses, or apps can usean API key. Add application restrictions based on your application type. Youcan only set one restriction type per API key.Select the Application restrictions tab in the Key restrictionssection.Choose the restriction type based on your application needs.
To add morethan one value for any restriction, type the first value, and then press theEnter key. Repeat to add values.Use None for testing purposes only.Use HTTP referrers for API clients that run on a webbrowser, so that only the specified pages can call the API. These types ofapplications expose their API keys publicly, so we recommendusing a instead.Seefor examples.Use IP addresses to limit API key access to certain IP addresses.Use Android apps for Android applications.
This option requiresadding your package name and SHA-1 signing-certificate fingerprint.Use iOS apps for iOS applications. This option requires adding atleast one iOS bundle identifier to restrict API calls to specific iOSbundles.Select the Save button.Adding HTTP restrictionsTo add HTTP restrictions:.Input at least one restriction into the form field.If your domain supports both HTTP and HTTPS, both restrictions must be addedseparately.To add more than one value, type the first value, and then press theEnter key. Repeat to add values.You can optionally use wildcard characters (.) for the subdomain and/orpath.The following table shows example scenarios and restrictions, from mostrestrictive to least restrictive. We recommend using the most restrictiveexample that fits your use case. ScenarioRestrictionsAllow a specific URL.Add a single restriction with an exact path. For example:. any URL in a single subdomain or naked domain.You must set at least two restrictions to allow an entire domain.
Google Docs Viewer Api Q Parameter Free
Set a restriction for the domain, without the trailingslash. For example:.
a second restriction for the domain that includes a wildcard forthe path. For example:. If your domain allows both HTTP and HTTPS you must add additionalrestrictions separately.Allow any subdomain URLs in a single domain.You must set at least two restrictions. Set a restriction for the domain, with a wildcard for the subdomain,and without the trailing slash. For example:. a second restriction for the domain that includes a wildcard forthe path, such as:.
Google Drive Viewer
If your domain allows both HTTP and HTTPS you must add additionalrestrictions separately.API restrictionsAPI restrictions specify which APIs can be called using the API key. AllAPI keys that are used in production applications should use API restrictions.To set API restrictions:.Select the API restrictions tab in the Key restrictionssection.Select an API name from the dropdown.Repeat the previous step for all APIs that your API key needs to call.Select the Save button.Viewing existing API keysUse GCP Console to view your existing API keys. Afternavigating to thepanel in GCP Console, existing API keys display underneath theAPI keys header.
What's next.Learn about.Learn about.Learn about.