title: Using Retrofit for Google's custom search via Google's REST API
body: <p>I've made an app that has a search function that is set to search from a custom Google search I made (using their Custom Search service). This doesn't have a Java library, so I'm using Retrofit to request using the REST API (<a href="https://developers.google.com/custom-search/json-api/v1/using_rest" rel="nofollow">https://developers.google.com/custom-search/json-api/v1/using_rest</a>), however I've run into a problem:</p>
  
  <p>Retrofit is working fine, but the request always returns a 400 error with the following information:
  <em>"domain": "usageLimits",    "reason": "keyInvalid"</em></p>
  
  <p>The API key I use in the request is the Android application key for my project in Google dev console. I assume this doesn't work however because Retrofit doesn't let Google know that I'm sending the request from my app?</p>
  
  <p>What are the possible fixes for this situation?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: I've confirmed that my APK is signed with the correct keys, and I triplequadruplequintuple-everything checked the SHA1 used to generate the apikey. I've generated a new api key about 3 or 4 times to see if that fixes it.</p>
  
  <h2>EDIT2:</h2>
  
  <p><strong>I got it to work!</strong></p>
  
  <p>You don't make an Android API key (it does not work with this), you make a browser API key, in which you set the allowed referers to all (potentially dangerous).</p>
  
  <p>You use that API key to request using Retrofit. I feel like this should be noted by Google: no doubt many would assume Android app? -> Android API key - but that is only the case when Google has made a library for the API.</p>