title: Generate OAuth 2.0 Access Token For PUT Request In Google Sheets API In JavaScript
body: <p><strong>GOAL</strong></p>
  
  <p>I would like to update some information in a Google Sheets document though a web service. I don't mind if the data is public, but it seems like I need to get an OAuth token in order to use <code>PUT https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}</code>as opposed to simply getting the data. However, I get back errors stating that I'm missing OAuth 2.0 credentials.</p>
  
  <p><strong>EXPECTATIONS</strong></p>
  
  <p>In order to do this, I assume that I need to first get credentials from <a href="https://console.developers.google.com/" rel="nofollow noreferrer">Google's Developer Console</a> . I currently have an OAuth 2.0 client ID and API key through that console. The API key is used to read the data and the OAuth would be used to write data.</p>
  
  <p>I then need to hit an endpoint of some kind with the OAuth information to get credentials that'll be used. I'm supposed to put this info into my <code>PUT</code> request. <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update" rel="nofollow noreferrer">This is the documentation I've found in regards to my request, but it's missing the authorization documentation.</a></p>
  
  <p><strong>QUESTIONS</strong></p>
  
  <p>1) Where is the endpoint that I'm hitting to get a refresh token and access token in Google's OAuth 2.0 stuffs? I've heard it's something like <code>https://accounts.google.com/o/oauth2/token</code>, but I'm not sure <em>how</em> to get the tokens. What do I need to pass? How do I pass that info? I can't find any documentation over it.</p>
  
  <p>2) After getting these tokens, how do I incorporate them into the <code>PUT</code> request to the Google Sheets API? Do the tokens go into the <code>Authorization</code> header or the <code>access_token</code> query parameter or something?</p>