Google Auth (OAuth 2.0) for Titanium
程序员文章站
2022-05-24 16:17:02
...
Google OAuth 2.0 for Titanium is a module for Appcelerator Titanium that i’ve created for use in my mobile apps. It allows to authenticate user with Google OAuth 2.0 and then work with Google Apis.
To understand how it works you must check Google Accounts Authentication and Authorization docs.
Example usage:
Check the demo App to see it in action. It is pretty simple but you will need to get your CLIENT_ID and CLIENT_SECRET from Google Api Console.
Titanium code:
Titanium demo:
Titanium module:
Download google-auth-for-titanium
https://bitbucket.org/miroslavmagda/google-auth-for-titanium
To understand how it works you must check Google Accounts Authentication and Authorization docs.
Example usage:
Check the demo App to see it in action. It is pretty simple but you will need to get your CLIENT_ID and CLIENT_SECRET from Google Api Console.
Titanium code:
//initialize module var GoogleAuth = require('modules/googleAuth'); var googleAuth = new GoogleAuth({ clientId : 'CLIENT_ID', clientSecret : 'CLIENT_SECRET', propertyName : 'googleToken', scope : ['https://www.googleapis.com/auth/tasks', 'https://www.googleapis.com/auth/tasks.readonly'] }); //create some button var sync = Ti.UI.createButton({ title : 'Sync' }); //do some action... sync.addEventListener('click', function() { googleAuth.isAuthorized(function() { Ti.API.info('Access Token: ' + googleAuth.getAccessToken()); //user is authorized so do something... just dont forget to add accessToken to your requests }, function() { //authorize first googleAuth.authorize(); }); });
Titanium demo:
Titanium module:
Download google-auth-for-titanium
https://bitbucket.org/miroslavmagda/google-auth-for-titanium
推荐阅读
-
【Google Calendar API v3】get events list with OAuth 2.0 &
-
ecshop使用Google API及OAuth2.0登录授权(PHP)
-
Google Auth (OAuth 2.0) for Titanium
-
ecshop使用Google API及OAuth2.0登录授权(PHP)
-
Google Oauth登录系统开发示例 oauth oauth2.0 oauth
-
Google Oauth登录系统开发示例 oauth oauth2.0 oauth
-
【Google Calendar API v3】get events list with OAuth 2.0 &