Skip to content

ejci/Google-Auth-for-Titanium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Auth (OAuth 2.0) for Titanium

Google Auth for Titanium is a module for Appcelerator Titanium. 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 example 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. If you don't now how to get CLIENT_ID or CLIENT_SECRET check this guide.

Titanium code:

:::javascript
//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'],
	loginHint : '[email protected]' 
});
//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:

Demo App

Author: Miroslav Magda Version 0.3.2

License

All code is open source and dual licensed under GPL and MIT. Check the individual licenses for more information.

About

Google Auth for Titanium

Resources

License

GPL-2.0, MIT licenses found

Licenses found

GPL-2.0
GPL-LICENSE.txt
MIT
MIT-LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •