Re: AuthorizationCodeInstalledApp.authorize() Failed

1,498 views
Skip to first unread message

Yaniv Inbar (יניב ענבר)

unread,
Nov 5, 2012, 7:34:08 AM11/5/12
to google-api-java-client
Please don't use AuthroizationCodeInstalledApp on Android.  Instead you need to use Google Play services.

In the next day or two, I will update calendar-android-sample and tasks-android-sample to show how this is done with version 1.12.0-beta:

Sorry for the delay.  We've been slowed down by hurricane Sandy.

-- Yaniv


On Thu, Nov 1, 2012 at 11:11 PM, YYJ <louis....@gmail.com> wrote:
Dear,

    I employed "Google API Client Library for Java, version 1.12.0-beta" and
move sample code in OAuth2Sample.java to my own XXX.apk.  When this APK runs,
it would fail at the following function:  
    com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize()

    The system logging message follows.

        W/System.err( 2219): java.lang.NoClassDefFoundError: org.mortbay.jetty.Server
        W/System.err( 2219): at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.   
                                             getRedirectUri (LocalServerReceiver.java:98)
        W/System.err( 2219): at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp. 
                                             authorize(AuthorizationCodeInstalledApp.java:76)

     Any suggestions might help ...


Yaniv Inbar (יניב ענבר)

unread,
Nov 11, 2012, 8:52:24 AM11/11/12
to google-api-java-client
It is important that you register your Android application on https://code.google.com/apis/console

Otherwise, it gives you a generic Android token which has a very low quota.

-- Yaniv


On Tue, Nov 6, 2012 at 9:18 PM, YYJ <louis....@gmail.com> wrote:
Dear Inbar:

  Thanks for your help.  I used the code segment in "Calendar Sample"; the APK functions correctly.
Access token for user could be retrieved correctly.  Thanks sincerely!

  Nevertheless I got stuck in another problem:
        "Access token would expire almost an hour (60 minites) later; and I called 

                accountManager.invalidateAuthToken(authToken);
                // ... (get access token once again here)
                ...  ... ...

          But I still get "the expired token"

  Would you please provide me clues to refresh token thru Google's API ?

   In addition, I do not provide client ID, client secrets in my own ***.APK
But Google account server still grant such a request and give my program "access token"   
It's a mystery to me !?  (Only client_secrets.json file appear in the APK source folder)

  Appreciate your help.


Reply all
Reply to author
Forward
0 new messages