gapi-to-graphql slides api not working - credentials error is returned
Hi, I have been trying gapi-to-graphql as dependency in a node.js project i'm currently working on. I'm working with Sheets V4 and Slides V1.
I have :
- a public spreadsheet on google sheets with a spreadsheetId
- a public presentation on google slides with a presentationId
- on google api dashboard (https://console.developers.google.com/apis/dashboard) I have a project with a created API Key credentials and I have enabled both Sheets & Slides API libraries
- There is no restrictions on API Key
I have developped a Node.js project with Apollo, Express and gapi-to-graphql dependencies.
I'm trying one read-only query for each library Sheets & Slides
query {
SheetsApi(key: "myAPIKey") {
spreadsheets {
get(spreadsheetId: "mySpreadsheetId", includeGridData: true) {
spreadsheetId
}
}
}
}
query {
SlidesApi(key: "myAPIKey") {
presentations {
get(presentationId: "myPresentationId") {
presentationId
}
}
}
}
The problem I have is that query on sheets is working (I retrieve spreadsheetId as response and i can add parameters to the query to fetch data from cells) but the query on slides is not working. The result of query on slides is :
Unexpected error value: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
As I'm pretty sure everything is well set up on my google account, Is there a chance that there is a bug on gapi-to-graphql/google_apis/slides-v1.js ?
Thanks by advance. David.
Want to work with me to fix it? email me at robert lancer at gmail - not sure how to DM on github
Hi Robert, thanks for the offer. Unfortunately I can not work on gapi-to-graphql right now. Maybe in the future, I'll keep that in mind. Best regards.
@davidhervas since the resolver uses axios to make request on google api, you can try injecting the token by using interceptors.
axios.interceptors.request.use(
config => {
const token = localStorage.getItem('token');
if (token) {
config.headers['Authorization'] = `Bearer ${token}`;
}
return config;
},
error => {
return Promise.reject(error);
},
);