Google Sheet API v4

后端 未结 3 2112
日久生厌
日久生厌 2020-12-03 22:52

I try to use example \"Read multiple ranges\":

https://sheets.googleapis.com/v4/spreadsheets/{SpreadsheetID}/values:batchGet?ranges=Sheet1!B:B&ran

相关标签:
3条回答
  • 2020-12-03 23:29

    You have to make sure to pass in the key=YOUR_API_KEY as the request parameter. For example:

    https://sheets.googleapis.com/v4/spreadsheets/{sheet_id}/values/Sheet1!A1:D5?key={YOUR_API_KEY}
    
    0 讨论(0)
  • 2020-12-03 23:37

    I believe you are missing API in the url. This is from google spreadsheet api doc.

    To acquire an API key:

    Open the Credentials page in the API Console.

    API keys: A request that does not provide an OAuth 2.0 token must send an API key. The key identifies your project and provides API access, quota, and reports.

    The API supports several types of restrictions on API keys. If the API key that you need doesn't already exist, then create an API key in the Console by clicking Create credentials > API key. You can restrict the key before using it in production by clicking Restrict key and selecting one of the Restrictions. To keep your API keys secure, follow the best practices for securely using API keys.

    After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.

    The API key is safe for embedding in URLs; it doesn't need any encoding.

    Google Spreadsheet Docs

    0 讨论(0)
  • 2020-12-03 23:47

    In addition to @skamble89's answer, this 403 error is usually caused by incorrect or missed some configuration in Authorizing Requests. If you're authorizing requests with OAuth 2.0, make sure you use the proper scope with it.

    Make sure you have a permission to call this spreadsheet and you enable the Sheets API in your developer console.

    0 讨论(0)
提交回复
热议问题