You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GApi.load('calendar','v3'); // for google api (https://developers.google.com/apis-explorer/)
75
+
GApi.load('myApiName','v1',BASE);
76
+
GApi.load('calendar','v3'); // for google api (https://developers.google.com/apis-explorer/)
77
77
78
-
GAuth.setClient(CLIENT);
79
-
GAuth.setScope("https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar.readonly"); // default scope is only https://www.googleapis.com/auth/userinfo.email
78
+
GAuth.setClient(CLIENT)
79
+
// default scope is only https://www.googleapis.com/auth/userinfo.email
The login should be triggered by a user action, or you might run into issues with popup blockers. More information about this can be found in the [Google APIs Client Library Documentation](https://developers.google.com/api-client-library/javascript/features/authentication#specifying-your-client-id-and-scopes).
$state.go('webapp.home'); // action after the user have validated that
181
-
// your application can access their Google account.
178
+
$scope.doSignup=function() {
179
+
GAuth.login().then(function(user) {
180
+
console.log(user.name+' is logged in');
181
+
$state.go('webapp.home'); // action after the user have validated that
182
+
// your application can access their Google account
182
183
}, function() {
183
-
console.log('login fail');
184
+
console.log('login failed');
184
185
});
185
-
};
186
+
};
186
187
}
187
188
]);
188
189
```
189
190
190
191
### Get user info
191
192
192
-
Get user info after login is very simple.
193
+
Get user info after login is very simple
193
194
194
195
```javascript
195
196
app.controller('myController', ['$rootScope',
196
197
functionmyController($rootScope) {
197
-
console.log($rootScope.gdata.getUser().name)
198
+
console.log($rootScope.gdata.getUser().name);
198
199
}
199
200
]);
200
201
```
201
202
202
203
```html
203
204
<h1>{{gdata.getUser().name}}</h1>
204
205
```
205
-
User object :
206
-
- user.email
207
-
- user.picture (url)
208
-
- user.id (Google id)
209
-
- user.name (Google account name or email if don't exist)
210
-
- user.link (link to Google+ page)
206
+
207
+
User object:
208
+
-`email`
209
+
-`picture` (url)
210
+
-`id` (Google id)
211
+
-`name` (Google account name or email if don't exist)
212
+
-`link` (link to Google+ page)
211
213
212
214
## Development
213
215
214
-
Gulp is used to minify angular-google-gapi.js (using Uglify). Execute 'npm install' (requires Node and NPM) to install the required packages.
216
+
`gulp` is used to minify `angular-google-gapi.js` (using Uglify). Execute `npm install` (requires `Node.js` and `npm`) to install the required packages.
215
217
216
-
Run "gulp" to generate a minified version (angular-google-gapi.min.js). Note that this requires gulp to be installed globally (via 'npm install -g gulp').
218
+
Run `gulp` to generate a minified version (`angular-google-gapi.min.js`). Note that this requires `gulp` to be installed globally (via `npm install -g gulp`).
0 commit comments