Reputation: 117
The question is simple. I got the access_token by Oauth 2. and I want to access spreadsheet on google to read. But When I read api from https://developers.google.com/sheets/ . I don't get where to put access_token or do i even need it.
I tried to put my access-token on url and failed.. for instance: var sample_url = "https://spreadsheets.google.com/pub?key=0Ago31FFWG3xZrdHF2bWNjcTJFLXJ6UUHYT3dEakdEaXc&hl=en&output=html?accesstoken=" + accesstoken; I got the response back. it says "{"data":{"error":{"code":403,"message":"The request cannot be identified with a client project. Please pass a valid API key with the request.","status":"PERMISSION_DENIED"}},"status":403,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"https://sheets.googleapis.com/v4/spreadsheets/1ZduILENRVcnzXTynV00j9puWJEvGgz-EcxOgoPRpOGI/values/A1:D3?ya29.Ci87A42OTqtIqXylTU7QxZALwJjRuf_oXf2FJ-MTY7QvXgWzPhZEKhi4Yhn7HVVV7g","headers":{"Accept":"application/json, text/plain, /"}},"statusText":""}" I know I have to attach the access-token somehow, but i don't know how. Do you guy have any idea for the spreadsheet api?
Thank you for reading this
Upvotes: 0
Views: 918
Reputation: 1609
I had a same requirement of accessing the google spreadsheet from the ionic cellphone, and we have used tabletop.js. Using this we were able to read the spreadsheet completely. Try this if it helps you anyway. https://github.com/jsoma/tabletop
Upvotes: 0
Reputation: 877
I am not familiar with the ionic-framework, but to use the access token, you should either add that into the HTTP headers (e.g. Authorization: Bearer ya29.xxxxxxxxxxxxxxxxxx
) or include that in your query string,
Ref: https://developers.google.com/identity/protocols/OAuth2InstalledApp#callinganapi
There is a mistake in your sample_url
, it should be &access_token=
instead of ?accesstoken=
It should be,
var sample_url = "https://spreadsheets.google.com/pub"
+ "?key=0Ago31FFWG3xZrdHF2bWNjcTJFLXJ6UUHYT3dEakdEaXc"
+ "&hl=en&output=html&access_token=" + accesstoken;
Upvotes: 0