android - Google Oauth2, can't retrieve one-time authorization code -


i have android app obtains access google services requesting onetime authorization code. each time user logs in auth code retrieved google. worked while stopped working specific user. user keep getting userrecoverableauthexception googles permissions request screen keep showing again , again. when try obtain normal access token user, there no problem.

the code use:

protected void doinbackground(void... params)              {              try               {                 // obtaining normal access token testing propose.                 string temptoken  = googleauthutil.gettoken(getapplicationcontext(), maccountname, "oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar");                 nlog.i(tag, "got token2: "+temptoken);                           // obtaining 1 time auth code                 string scope = string.format("oauth2:server:client_id:%s:api_scope:%s",client_id, textutils.join(" ", scopes));                 mservertoken = googleauthutil.gettoken(getapplicationcontext(), maccountname, scope);                 nlog.i(tag, "got code: "+mservertoken);                 sendgoogleloginresult(result_ok, null, mservertoken);                 finish();             }               catch (userrecoverableauthexception e)               {                 if (e !=null && e.getintent() != null && authexceptioncount <3)                 {                     authexceptioncount++;                     intent recoveryintent = e.getintent();                     startactivityforresult(recoveryintent, google_recovery_activity_request);                 }                 else                 {                     log.i(tag, "userrecoverableauthexception there no intent: ", e);                     sendgoogleloginresult(result_canceled, null, mservertoken);                     finish();                 }             }               catch (ioexception e) {                 log.i(tag, "transient error encountered: ", e);                 sendgoogleloginresult(result_canceled, null, mservertoken);                 finish();              } catch (googleauthexception e) {                 // unrecoverable.                  log.e(tag, "unrecoverable authentication exception: " + e.getmessage(), e);                  sendgoogleloginresult(result_canceled, null, mservertoken);                  finish();             }             return null;         } 


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -