Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get the Google Authentication Access Token? #18

Open
ChanakyaSrinivas opened this issue Nov 28, 2017 · 5 comments
Open

Unable to get the Google Authentication Access Token? #18

ChanakyaSrinivas opened this issue Nov 28, 2017 · 5 comments

Comments

@ChanakyaSrinivas
Copy link

Hi All,

How to get Google Authentication Access Token for titanium mobile apps (ios and android) ?

@chmiiller
Copy link
Collaborator

Please check the example folder. There is a JS file in there which you can better understand how to initialize and read the response properties. There is also a video showing how to register your app

@ChanakyaSrinivas
Copy link
Author

ChanakyaSrinivas commented Nov 29, 2017

Hi,

As per your suggestion I flowed. Now am able to get access token from response properties.

Actually my requirement is to perform the different operations on google calendar like below

  1. Showing list of events
  2. Create new event
  3. Edit event

Now am trying to show the calendar events based on generated token but am getting below error

Error 1
{
"error":{
"errors":[
{
"domain":"global",
"reason":"authError",
"message":"Invalid Credentials",
"locationType":"header",
"location":"Authorization"
}
],
"code":401,
"message":"Invalid Credentials"
}
}

Error 2
{
"error":{
"errors":[
{
"domain":"usageLimits",
"reason":"dailyLimitExceededUnreg",
"message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp":"https://code.google.com/apis/console"
}
],
"code":403,
"message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}

sample code:

`Google.addEventListener('login', function(e) {

try{
	Ti.API.info(' ***** RESULT: ' + JSON.stringify(e));
	Ti.API.info(' : e.token ' + e.token);
	Ti.API.info(' : e.id ' + e.id);
	Ti.API.info(' : e.idToken ' + e.idToken);
	Ti.API.info(' : e.email ' + e.email);
	Ti.API.info(' : e.givenName ' + e.givenName);
	getAllEvents(e.id , e.token);
}catch(e1){
	
}

});

function getAllEvents(calendarId , access_token) {

var calenderURL = 'https://www.googleapis.com/calendar/v3/calendars/' + calendarId + '/events';
Ti.API.info('calenderURL: ' + calenderURL);
var xhrList = Ti.Network.createHTTPClient({
	// function called when the response data is available
	onload : function(e) {
		try {
			var eventsResp = JSON.parse(this.responseText);
			Ti.API.info('CPS getAllEvents: ' + eventsResp);
		} catch(e) {

		}
	},
	// function called when an error occurs, including a timeout
	onerror : function(e) {
		Ti.API.error('getAllEvents HTTP error: ' + e);
	},
});
xhrList.open("GET", calenderURL);
 xhrList.setRequestHeader('Authorization', "Bearer " + access_token);
xhrList.setRequestHeader('Content-type', 'application/json');
xhrList.send();

}`

Can you please help me out how to get the list calendar events based on access token?

@chmiiller chmiiller added enhancement Hacktoberfest Hacktoberfest label labels Oct 3, 2018
@chmiiller
Copy link
Collaborator

I'm not so sure if I'm able to fix this issue. Does anyone have experience with Calendar?

@chmiiller
Copy link
Collaborator

Actually, I think the very best is to close this issue and open another one with more details on how to get information from Google Calendar. @ChanakyaSrinivas can you please do this?

@AppWerft
Copy link
Owner

AppWerft commented Oct 5, 2018

Yes I have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants