Google Auth (OAuth 2.0) for Titanium

此模块为Appcelerator Titanium提供Google OAuth2.0认证功能,并允许开发者使用Google API。用户需从Google API Console获取客户端ID和密钥进行配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[url=https://bitbucket.org/miroslavmagda/google-auth-for-titanium]Google OAuth 2.0 for Titanium[/url] is a module for [url=http://www.appcelerator.com/platform]Appcelerator Titanium[/url] 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 [url=https://developers.google.com/accounts/docs/OAuth2InstalledApp]Google Accounts Authentication and Authorization docs[/url].

[b]Example usage:[/b]
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 [url=https://code.google.com/apis/console/]Google Api Console[/url].

[b]Titanium code:[/b]

//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();
});
});


[b]Titanium demo:[/b]
[img]http://dl.iteye.com/upload/attachment/0081/8617/8ba46b46-dbfe-3519-a853-96e86a0fb3d4.png[/img]

[b]Titanium module:[/b]
[url=http://dl.iteye.com/topics/download/af8f9bd8-0a49-34f6-8863-73cf650a8b13]Download google-auth-for-titanium[/url]

[url=https://bitbucket.org/miroslavmagda/google-auth-for-titanium]https://bitbucket.org/miroslavmagda/google-auth-for-titanium[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值