I installed
npm install --save @types/gapi.auth2
How to import and use it?
I installed
npm install --save @types/gapi.auth2
How to import and use it?
don’t open a new thread for the same problem, it just isn’t necessary!
you already asked the same thing here: How to use TypeScript definitions @types in ionic2 project
read http://ionicframework.com/docs/v2/faq/ to get the idea of typings/@types
note: rc0 uses @types see the changelog: https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#typings
all you have done now is installed typeScript definitions for Google API Client, did you install/add the Google API Client library too?
@fishgrind So sorry for duplicating, but I didn’t find solution
I have installed
npm install --save @types/gapi
home.html
import { Component } from ‘@angular/core’;
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
test_init(){
var auth = gapi.auth2.init({
client_id: 'xxxx.googleusercontent.com'
});
}
}
home.html
<button ion-button (click)="test_init()">Test auth</button>
index.htm (add google api client)
<script src="https://apis.google.com/js/api:client.js"></script>
but it has error in console
Cannot read property 'init' of undefined
do you want to use google sign-in?
if so are you aware of this?
I want to use Google Drive API, and I need access_token.
If I use Google Plus native, it doesn’t run on browser