API Keys
API Keys
API Keys
Overview
This tutorial covers What Are API keys Setting up API keys API projects Server side Browser Security Quotas API Error Messages
API Keys
API Keys and GCS
Keys are access tokens that allow GCS queries Not strictly authentication or authorization tokens Google API services require API keys for access GCS is an aspect of a Google API (Search API for Shopping) Simply a way to regulate/control Google API access *All* GCS/Shopping API queries must contain an API key Keys are unique to the customer and should not be shared https://developers.google.com/console/help/#generatingdevkeys GCS cx
https://www.googleapis.com/shopping/search/v1/cx:014034025922634248784:wxuo9fqco9m/products? country=us&alt=atom&key=AIzaSyDAH9n6vu4JGg7iDcW7UtrO4Y9q0v2Pfbo&q=digital+camera
API Key
API Keys
Creating API Keys
Keys setup during GCS instance creation Each GCS instance should have at least 1 Search API key (server-side) 1 SAYT Key (browser key) Keys white-listed for higher quotas during account provisioning
Login using the @gmail account you want to own the GCS instance
(NOTE: GCS instances are not transferable so this login should be generic login)
Goto https://code.google.com/apis/console/?api=shopping Click on "Services" and enable "Shopping API" For Search API key, click "API Access > New Server Key" For SAYT key, use "Browser Key" Add IP or Referrer Restricts as necessary Add userIP= user queries per second for Server keys Provide API keys to Google for Provisioning
API Keys
Creating API Keys
API Keys
Creating API Keys
For Search API key, click "API Access > New Server Key" Note: browser key enabled by default. example below, the browser key was deleted from the API project
API Project
API Keys
Creating API Keys For SAYT key, use "Browser Key" Add Referrer Restricts
Referrer Restricts
https://developers.google.com/console/help/#monitoringandfiltering
/products?alt=atom&country=us&q=android...&userIp=1.2.3.4
3. API Quotas
API Quotas
Default API quotas 2500 queries per rolling 24 hours API quotas enforced at the *PROJECT* level If SAYT and Search keys uses same project, quota shared Could cause outage if SAYT key quota is exhausted API keys whitelisted during provisioning
4. API Errors
API Errors
Common API key errors Use API key in query in json mode
https://www.googleapis.com/shopping/search/v1/cx:014034025922634248784: wxuo9fqco9m/products? country=us&alt=json&key=AIzaSyDAH9n6vu4JGg7iDcW7UtrO4Y9q0v2Pfbo&q=digital+camer a
API Errors
dailyLimitExceeded: The daily quota limit was exceeded. Contact Enterprise support to increase the quota.
{ "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceeded", "message": "Daily Limit Exceeded" } ], "code": 403, "message": "Daily Limit Exceeded" } }
userRateLimitExceeded: The per user QPS is set too low. Check to see if you are transmitting the &userIp= of the end user.
{ "error": { "errors": [ { "domain": "usageLimits", "reason": "userRateLimitExceeded", "message": "User Rate Limit Exceeded", "debugInfo": "QuotaState: USER_QPS_THROTTLED" } ], "code": 403, "message": "User Rate Limit Exceeded" } }
API Errors
accessNotConfigured: The API key maybe restricted to only certain origin IP addresses (if server) or referrers (if browser)
{ "error": { "errors": [ { "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured", "debugInfo": "QuotaState: BLOCKED" } ], "code": 403, "message": "Access Not Configured" } }
Thank You
https://developers.google.com/commerce-search