Ionic 2 and Google Drive API v3 problems


#1

Hello,

I’m trying to use the Google Drive API v3 in an Ionic 2.3.0 app.

I followed a few guides and came to the following steps:

  1. Download and load the API script in index.html
    <script src="https://apis.google.com/js/api.js"></script>

  2. Add the types:

npm install --save @types/gapi
npm install --save @types/gapi.auth2

… and in tsconfig.json

{
    compilerOptions {
        (...)
        "types": ["gapi", "gapi.auth2"]
    }
}

… and finally init the library in main.ts

declare var gapi: any;
gapi.load('client:auth2', () => {});

Unfortunately ionic serve is failing with:

[12:17:49]  typescript error
[12:17:49]  typescript error
            Cannot find type definition file for 'gapi'.
            Cannot find type definition file for 'gapi.auth2'.

This means that the changes in tsconfig.json aren’t working. Does any of you know what might be going on?

Thank you!

AP


#2

Hi, have you ever managed to find a solution for this? Im struggling with the same issue.


#3

No, unfortunately :frowning: . I ended-up using Dropbox for my project!