在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):maximepvrt/angular-google-gapi开源软件地址(OpenSource Url):https://github.com/maximepvrt/angular-google-gapi开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):Angular Google GApiAn AngularJS module for using all Google Apis and your Google Cloud Endpoints (Google App Engine) with OAuth. This module uses Google APIs Client Library for JavaScript, available for all GApis. ExampleRequirementsInstallationAdd libraryThis module is available as $ bower install --save angular-google-gapi it's also available as a $ npm install --save angular-google-gapi or you may download the latest release <script type="text/javascript" src="/angular-google-gapi/dist/angular-google-gapi.min.js"></script> Add dependencyvar app = angular.module('myModule', ['angular-google-gapi']); Configurationwithout Google Authadd app.run(['GApi', 'GAuth',
function(GApi, GAuth) {
var BASE = 'https://myGoogleAppEngine.appspot.com/_ah/api';
GApi.load('myApiName', 'v1', BASE).then(function(resp) {
console.log('api: ' + resp.api + ', version: ' + resp.version + ' loaded');
}, function(resp) {
console.log('an error occured during loading api: ' + resp.api + ', resp.version: ' + version);
});
}
]); with Google Authadd app.run(['GAuth', 'GApi', 'GData', '$state', '$rootScope',
function(GAuth, GApi, GData, $state, $rootScope) {
$rootScope.gdata = GData;
var CLIENT = 'yourGoogleAuthAPIKey';
var BASE = 'https://myGoogleAppEngine.appspot.com/_ah/api';
GApi.load('myApiName','v1',BASE);
GApi.load('calendar','v3'); // for google api (https://developers.google.com/apis-explorer/)
GAuth.setClient(CLIENT)
// default scope is only https://www.googleapis.com/auth/userinfo.email
GAuth.setScope('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar.readonly');
// load the auth api so that it doesn't have to be loaded asynchronously
// when the user clicks the 'login' button.
// That would lead to popup blockers blocking the auth window
GAuth.load();
// or just call checkAuth, which in turn does load the oauth api.
// if you do that, GAuth.load(); is unnecessary
GAuth.checkAuth().then(
function (user) {
console.log(user.name + ' is logged in');
$state.go('webapp.home'); // an example of action if it's possible to
// authenticate user at startup of the application
},
function() {
$state.go('login'); // an example of action if it's impossible to
// authenticate user at startup of the application
}
);
}
]);
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论