Hardik Kanjariya ツ
Hardik Kanjariya ツ

Reputation: 636

How to get GoogleSheet_ID to use it in 'google_drive' gem

I have user google_drive gem, Using oAuth2 I have received the access_token details too. But while I am going to fetch content of one of my google sheet, I found error notfound as like below :

notFound: File not found: 1s-APBHuCQLhvAFUeAQyFpyJJiNwyy_ZenQUe91WDru0

Below is my code :

session = GoogleDrive.login_with_oauth(@client) // @client is my googleAuth Object
sheet = session.spreadsheet_by_key("1s-APBHuCQLhvAFUeAQyFpyJJiNwyy_ZenQUe91WDru0").worksheets[0]

My Sheet URL is : https://docs.google.com/spreadsheets/d/1s-APBHuCQLhvAFUeAQyFpyJJiNwyy_ZenQUe91WDru0/edit#gid=0

Please help me out to find Google Sheet Id.

Upvotes: 1

Views: 413

Answers (1)

KENdi
KENdi

Reputation: 7771

I think the ID you are using is correct, maybe other reason is causing this issue.

If you check the Google Drive API error,

404: File not found: {fileId}

The user does not have read access to a file, or the file does not exist.

Suggested action: Report to users that they do not have read access to the file or that the file does not exist. Tell them that they should ask the owner for permission to the file.

Maybe you are missing some authorization scopes. Try to use the full permission with this.

Upvotes: 1

Related Questions