rgoogle-sheets-apigooglesheets4

Accessing the spreadsheet using access token in R using googlesheets4


I'm trying to access the sheet using oAuth 2.0 in R.

I have generated the access token.

I am not clear of how to retrieve the data from the above mentioned sheet.

I have tried to access the data using this piece of code

sampleData <- GET("https://sheets.googleapis.com/v4/spreadsheets/1qS66SgO6Uc958WTY1_2I7zN58MxtleLN5PbadhjIBqg",
                          add_headers("Authorization" = new_access_token))

    data_list <- content(sampleData, "parsed")

Can anyone provide me a way to proceed further?

Thanks in advance!!


Solution

  • Add the sheet name to the end e.g

    /values/Sheet1
    

    This will get you the entire sheet. To get details of a range include A1 notation

    GET https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId/values/Sheet1!A1:D5