[android-developers] Google Calendar API v3 OAuth 2.0

2013-05-14 Thread John Goche
Hello,

I am trying to use the Java API for Google Calendar v3 on Android, but I am
stuck. Here is what I've done so far:

Created a google account my...@gmail.com for my application and
registered it with my debug key on code.google.com/apis/console where I
have created all the auth data (client ID, certificate fingerprint, api
key, etc...)

Added some code to my android application:

{

final HttpTransport transport = AndroidHttp.newCompatibleTransport();

final JsonFactory jsonFactory = new GsonFactory();

GoogleAccountCredential credential;

credential = GoogleAccountCredential.usingOAuth2(this,
CalendarScopes.CALENDAR);

credential.setSelectedAccountName(myemailh...@gmail.com);

calendarClient = new
com.google.api.services.calendar.Calendar.Builder(transport,   jsonFactory,
credential)
.setApplicationName(My App Name/1.0).build();

}

Some code on the net also has:

GoogleCredential gc = new GoogleCredential.Builder()
  .setTransport(transport)
  .setJsonFactory(jsonFactory)
  .setServiceAccountId(850381918262.apps.googleusercontent.com)
  .setServiceAccountScopes(CalendarScopes.CALENDAR)
  .setServiceAccountUser(u...@gmail.com)
  /*.setServiceAccountPrivateKeyFromP12File(new
File(D:/3cd8Xd635e-privatekey.p12))*/
  .build();

But I don't have a private key, so where would I get it. And what would I
do with the GoogleCredential object?
I've seen there is a credential.getToken() function but I'm not sure how to
use it. From what I gather my application should initiate a process where
it asks the user to authorize myapplicat...@google.com to access
myemailh...@google.com 's calendar data, but how do I setup this process?

Also what is the difference between a GoogleAccountCredential and a
GoogleCredential? Which one do I need? Also some posts make reference to a
client secret, but I do not have one (android applications do not have a
secret it seems).

I've searched and searched the web but could only find vague information.
And the sample google calendar api application does not set up access with
the sequence I describe.

I know I need to

Authenticate using OAuth2 for installed applications
Somehow prompt the user if the app can access their calendar data.
Connect and manipulate calendar data.

Could someone here please help me?

Thanks.

John Goche

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Google Calendar API: drawbacks of using Gingerbread vs. Ice Cream Sandwich etc...

2013-04-14 Thread John Goche
Hello,

I've got a few questions regarding the Google Calendar API for Android.

1. Do I really need to be running Ice Cream Sandwich or later to use
the Google Calendar API? The docs seem to imply this but on the
other hand I've found some code which works with API 8.

I've got a Gingerbread device where I can use AccountManager stuff
but I'm not sure what the limitations of this platform as far as the
Google Calendar API is concerned are.

2. Can I debug on the emulator/use the google play application
on the emulator or do I need a real device to debug and test
my google calendar code?

Thanks for your feedback,

John Goche

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] google calendar api access not configured in android

2013-01-07 Thread Bhavesh Patel
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 
Forbidden { code: 403, errors: [  {domain: usageLimits,   
 message: Access Not Configured,reason: accessNotConfigured  } 
], message: Access Not Configur

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Google Calendar API v3 with AccountManager not working for some accounts?

2012-11-22 Thread Christopher Masser



 I'm using the AccountManager getAuthToken(..) method to retrieve a token 
for Google Calendar sync.

While sync works in most cases, several users report the following error 
when trying to get the calendarList of the Google calendar API:


 com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 
Unauthorized{code : 401,errors : [ {domain : global,location : 
Authorization,locationType : header,message : Invalid 
Credentials,reason : authError} ],message : Invalid Credentials}
Their native Android calendar app continues to sync normally.i.e., they do have 
internet connection and they do have registered accounts on their device.Here 
is what I do:

AccountManager accountManager = AccountManager.get(this);Account[] accounts = 
accountManager.getAccountsByType(com.google);...//for each 
account:...accountManager.invalidateAuthToken(account.type, 
null);accountManager.getAuthToken(account,
oauth2:https://www.googleapis.com/auth/calendar;, true, new 
AccountManagerCallbackBundle(){ public void 
run(AccountManagerFutureBundle future) {try{ 
Bundle bundle = future.getResult(); 
if(bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
String token = bundle.getString(AccountManager.KEY_AUTHTOKEN);  
  AfterGetToken(token);  }else {  
if(bundle.containsKey(AccountManager.KEY_INTENT)) {  
Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
  intent.setFlags(intent.getFlags()  ~Intent.FLAG_ACTIVITY_NEW_TASK);  
activity.startActivityForResult(intent, 
REQUEST_AUTHENTICATE);  //-start all over in 
onActivityResult  }  }
}catch(Exception e){e.printStackTrace();
invalidateToken(account, null);//-start again} 
   } }, null);


 
 private void AfterGetToken(String myToken){


 GoogleCredential credential = new 
GoogleCredential().setAccessToken(myToken);


 CalendarService = new 

com.google.api.services.calendar.Calendar.Builder(transport,

new JacksonFactory(), null)

.setApplicationName(MY_APP_NAME)

.setHttpRequestInitializer(credential)

.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {

public void initialize(JsonHttpRequest request) throws IOException {

com.google.api.services.calendar.CalendarRequest calendarRequest = 
(CalendarRequest) request;

calendarRequest.setKey(MY_API_KEY);

calendarRequest.setOauthToken(credential.getAccessToken());

}

}).build();


 CalendarList calendarList = null;

* try*{ 

calendarList = CalendarService.calendarList().list().execute();

}*catch* (Exception e) {

 e.printStackTrace();

}

//do stuff with calendarList

}


 
 //These are my imports:

*import* android.accounts.Account;

*import* android.accounts.AccountManager;

*import* com.google.api.client.googleapis.auth.oauth2.GoogleCredential;

*import* com.google.api.client.http.HttpTransport;

*import* com.google.api.client.http.javanet.NetHttpTransport;

*import* com.google.api.client.http.json.JsonHttpRequest;

*import* com.google.api.client.http.json.JsonHttpRequestInitializer;

*import* com.google.api.client.json.jackson.JacksonFactory;

*import* com.google.api.services.calendar.CalendarRequest;

*import* com.google.api.services.calendar.model.*CalendarList*;


 
 Thanks for your help!

Christopher

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Google Calendar API

2012-08-16 Thread Kennet
Hi

I am new to android. 

I am trying to develop an app that uses google calendar but I am having a 
hard time understanding the API
would it be possible for any of you to describe how you make your app 
interact with google calendar? 

-what should I write in my .java file?
-what should I write in my manifest?
-other stuff that needs to be done to make this work?

Kind regards 
Kennet

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Google Calendar API

2012-08-16 Thread Michael Chan
Have you seen
http://developer.android.com/guide/topics/providers/calendar-provider.html?


On Tue, Aug 14, 2012 at 1:20 PM, Kennet kennetsund...@gmail.com wrote:

 Hi

 I am new to android.

 I am trying to develop an app that uses google calendar but I am having a
 hard time understanding the API
 would it be possible for any of you to describe how you make your app
 interact with google calendar?

 -what should I write in my .java file?
 -what should I write in my manifest?
 -other stuff that needs to be done to make this work?

 Kind regards
 Kennet

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] google calendar api on android

2011-07-12 Thread leslie.karpati
Hi,

I'm started to use the Google Calendar Api and now I'm ok with the
authetication, get the calendar list, rename the calendars, and add
event with specified time and title to a selected calendar.

I'm started to use the model from the  calendar-v2-atom-android-sample
(http://code.google.com/p/google-api-java-client/source/browse/
calendar-v2-atom-android-sample/src/com/google/api/client/sample/?
repo=samples#sample%2Fcalendar%2Fandroid%2Fmodel) and i figured out
what I have to add to the model for the events because I read this:
http://www.google.com/support/forum/p/apps-apis/thread?tid=3b948784a9502531hl=en

But now I have to add a recurrention for my events, and I alredy read
this: 
http://code.google.com/apis/calendar/data/2.0/developers_guide_java.html#CreatingRecurring,
but not really clear what is the content of the public class
Recurrence {}, and where and how should I define the
setRecurrence(Recurrence recurr)() function.

Please help,
Leslie.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] google calendar api on android

2011-07-12 Thread Mark Murphy
This is a list for Android SDK development. Questions about the Google
Calendar GData APIs belong on a list for Google Calendar GData SDK
development.

On Tue, Jul 12, 2011 at 7:49 AM, leslie.karpati
leslie.karp...@gmail.com wrote:
 Hi,

 I'm started to use the Google Calendar Api and now I'm ok with the
 authetication, get the calendar list, rename the calendars, and add
 event with specified time and title to a selected calendar.

 I'm started to use the model from the  calendar-v2-atom-android-sample
 (http://code.google.com/p/google-api-java-client/source/browse/
 calendar-v2-atom-android-sample/src/com/google/api/client/sample/?
 repo=samples#sample%2Fcalendar%2Fandroid%2Fmodel) and i figured out
 what I have to add to the model for the events because I read this:
 http://www.google.com/support/forum/p/apps-apis/thread?tid=3b948784a9502531hl=en

 But now I have to add a recurrention for my events, and I alredy read
 this: 
 http://code.google.com/apis/calendar/data/2.0/developers_guide_java.html#CreatingRecurring,
 but not really clear what is the content of the public class
 Recurrence {}, and where and how should I define the
 setRecurrence(Recurrence recurr)() function.

 Please help,
 Leslie.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] google calendar api

2011-07-12 Thread leslie.karpati
Sziasztok,

van valakinek tapasztalata a google calendar api használatára
androidon?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] google Calendar API test problem

2008-12-19 Thread shleeforandroid

hi all

i tried to use sample code from gdata-src.java-1.28.0.java.zip to
test google Calendar API.

CalendarService myService = new CalendarService(a-
b-1,http,www.google.com);

try {
  myService.setUserCredentials(USERNAME, PASSWORD);
  ...
} catch(ServiceException e) {
 // Server side error
Log.e(TestSchedule(),e.toString());
   }

== met following exception
 12-19 13:03:14.940: WARN/System.err(9347):
com.google.gdata.util.AuthenticationException: Error authenticating
(check service name)

and i modify code like this
CalendarService myService = new CalendarService(a-b-1);
== met following exception
12-19 13:03:16.710: WARN/System.err(9347):
com.google.gdata.util.AuthenticationException: Error connecting with
login URI

so i search google groups and so on i reach the content

http://groups.google.com/group/android-developers/browse_thread/thread/a029a9973143f621/d190d67dee6a0bda?show_docid=d190d67dee6a0bda

i used that (http://www.shanaghy.com/gdatamod/ ) files to gdata\java
\lib folder. But my emulator died.

so i tired 2th method.


===
I modified the gdata source to override the https cert verifier in
the
following places.
com\google\gdata\client\GoogleAuthTokenFactory.java(461):
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
com\google\gdata\client\authn\oauth\OAuthHttpClient.java(43):
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(303): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(371): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(431): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\HttpGDataRequest.java(320):
HttpURLConnection uc = (HttpURLConnection)
requestUrl.openConnection();


The modified code looks like this:


// Open connection
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
if ( urlConnection instanceof HttpsURLConnection ) {
HttpsURLConnection ucs = (HttpsURLConnection) urlConnection;
ucs.setHostnameVerifier( new X509HostnameVerifier(){
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
@Override
public void verify(String arg0, SSLSocket arg1) throws
IOException {
}
@Override
public void verify(String arg0, X509Certificate arg1)
throws SSLException {
}
@Override
public void verify(String arg0, String[] arg1, String[]
arg2) throws SSLException {
}
});
}
=

i wanted to make JAR files, so i created project with eclipse and
modified each files you recommeded.

BUT i have some problem below that.

[javac] D:\java\workspace\324\java\src\com\google\gdata\client\http
\HttpGDataRequest.java:42: package org.apache.http.conn.ssl does not
exist
[javac] import org.apache.http.conn.ssl.*;
[javac] ^
[javac] D:\java\workspace\324\java\src\com\google\gdata\client\http
\HttpGDataRequest.java:317: cannot find symbol
[javac] symbol  : class X509HostnameVerifier
[javac] location: class
com.google.gdata.client.http.HttpGDataRequest
[javac] ucs.setHostnameVerifier( new X509HostnameVerifier()
{
[javac]  ^

I don't know how do i do that ?
I can't solve the problem.

i added the android.jar files throgh buildpath confiuration to import
org.apache.http.conn.ssl.X509HostnameVerifier but i meet the above
problem.
i really want  to make new JAR files. Plz tell me the solution more
details as step by step because i',m beginner with eclipse and Java.
Or any solutions do you have?

Regards

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] google Calendar API test problem

2008-12-19 Thread bear...@hanmail.net

hi

i tried to use sample code from gdata-src.java-1.28.0.java.zip to
test google Calendar API.

CalendarService myService = new CalendarService(a-
b-1,http,www.google.com);

try {
  myService.setUserCredentials(USERNAME, PASSWORD);
  ...
} catch(ServiceException e) {
 // Server side error
Log.e(TestSchedule(),e.toString());
   }

== met following exception
 12-19 13:03:14.940: WARN/System.err(9347):
com.google.gdata.util.AuthenticationException: Error authenticating
(check service name)

and i modify code like this
CalendarService myService = new CalendarService(a-b-1);
== met following exception
12-19 13:03:16.710: WARN/System.err(9347):
com.google.gdata.util.AuthenticationException: Error connecting with
login URI

so i search google groups and so on i reach the content

http://groups.google.com/group/android-developers/browse_thread/thread/a029a9973143f621/d190d67dee6a0bda?show_docid=d190d67dee6a0bda

i used that (http://www.shanaghy.com/gdatamod/ ) files to gdata\java
\lib folder. But my emulator died.

so i tired 2th method.


===
I modified the gdata source to override the https cert verifier in
the
following places.
com\google\gdata\client\GoogleAuthTokenFactory.java(461):
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
com\google\gdata\client\authn\oauth\OAuthHttpClient.java(43):
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(303): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(371): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\AuthSubUtil.java(431): HttpURLConnection
httpConn = (HttpURLConnection) url.openConnection();
com\google\gdata\client\http\HttpGDataRequest.java(320):
HttpURLConnection uc = (HttpURLConnection)
requestUrl.openConnection();


The modified code looks like this:


// Open connection
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
if ( urlConnection instanceof HttpsURLConnection ) {
HttpsURLConnection ucs = (HttpsURLConnection) urlConnection;
ucs.setHostnameVerifier( new X509HostnameVerifier(){
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
@Override
public void verify(String arg0, SSLSocket arg1) throws
IOException {
}
@Override
public void verify(String arg0, X509Certificate arg1)
throws SSLException {
}
@Override
public void verify(String arg0, String[] arg1, String[]
arg2) throws SSLException {
}
});
}
=

i wanted to make JAR files, so i created project with eclipse and
modified each files you recommeded.

BUT i have some problem below that.

[javac] D:\java\workspace\324\java\src\com\google\gdata\client\http
\HttpGDataRequest.java:42: package org.apache.http.conn.ssl does not
exist
[javac] import org.apache.http.conn.ssl.*;
[javac] ^
[javac] D:\java\workspace\324\java\src\com\google\gdata\client\http
\HttpGDataRequest.java:317: cannot find symbol
[javac] symbol  : class X509HostnameVerifier
[javac] location: class
com.google.gdata.client.http.HttpGDataRequest
[javac] ucs.setHostnameVerifier( new X509HostnameVerifier()
{
[javac]  ^

I don't know how do i do that ?
I can't solve the problem.

i added the android.jar files throgh buildpath confiuration to import
org.apache.http.conn.ssl.X509HostnameVerifier but i meet the above
problem.
i really want  to make new JAR files. Plz tell me the solution more
details as step by step because i',m beginner with eclipse and Java.
Or any solutions do you have?

Regards

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---