2013-07-28 9 views
5

अपवाद:.GoogleAuthException: Google एसएसओ करते समय अज्ञात।

07-28 14:36:13.140: W/System.err(11382): com.google.android.gms.auth.GoogleAuthException: Unknown 
07-28 14:36:13.140: W/System.err(11382): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source) 
07-28 14:36:13.140: W/System.err(11382): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source) 
07-28 14:36:13.148: E/AndroidRuntime(11382): FATAL EXCEPTION: main 

मेरे ऊपर साइन कोड:

public class Signup extends Activity { 

     final private String CLIENT_ID = <android-client-id>; 
     final private List<String> SCOPES = Arrays.asList(new String[]{ 
      "https://www.googleapis.com/auth/plus.login" 
     }); 
     private String webId = <web-client-id>; 


     private GoogleAccountCredential mCredential; 

     private EditText mExchangeCodeEditText; 
     private EditText mIdTokenEditText; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.activity_google); 
     //mExchangeCodeEditText = (EditText) findViewById(R.id.editTextExchangeCode); 
     // mIdTokenEditText = (EditText) findViewById(R.id.editTextIdToken); 

     // initiate a credential object with drive and plus.login scopes 
     // cross identity is only available for tokens retrieved with plus.login 
     mCredential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(SCOPES.get(0))); 

     // user needs to select an account, start account picker 
     startActivityForResult(
      mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); 
     } 

     /** 
     * Handles the callbacks from result returning 
     * account picker and permission requester activities. 
     */ 
     @Override 
     protected void onActivityResult(
      final int requestCode, final int resultCode, final Intent data) { 
     switch (requestCode) { 
     // user has returned back from the account picker, 
     // initiate the rest of the flow with the account he/she has chosen. 
     case REQUEST_ACCOUNT_PICKER: 
      String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); 
      if (accountName != null) { 
      mCredential.setSelectedAccountName(accountName); 
      new RetrieveExchangeCodeAsyncTask().execute(); 
      new RetrieveJwtAsyncTask().execute(); 
      } 
      break; 
     // user has returned back from the permissions screen, 
     // if he/she has given enough permissions, retry the the request. 
     case REQUEST_AUTHORIZATION: 
      if (resultCode == Activity.RESULT_OK) { 
      // replay the same operations 
      new RetrieveExchangeCodeAsyncTask().execute(); 
      new RetrieveJwtAsyncTask().execute(); 
      } 
      break; 
     } 
     } 

     /** 
     * Retrieves the exchange code to be sent to the 
     * server-side component of the app. 
     */ 
     public class RetrieveExchangeCodeAsyncTask 
      extends AsyncTask<Void, Boolean, String> { 

     @Override 
     protected String doInBackground(Void... params) { 

      String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", 
       CLIENT_ID, TextUtils.join(" ", SCOPES)); 
      try { 

       GoogleAccountCredential.usingAudience(Signup.this, "server:client_id:" + webId); 
      return GoogleAuthUtil.getToken(

       Signup.this, mCredential.getSelectedAccountName(), scope); 
      } catch (UserRecoverableAuthException e) { 
      startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); 
      } catch (Exception e) { 
      e.printStackTrace(); // TODO: handle the exception 
      } 
      return null; 
     } 

     @Override 
     protected void onPostExecute(String code) { 
      // exchange code with server-side to retrieve an additional 
      // access token on the server-side. 
     // mExchangeCodeEditText.setText(code); 
      Log.d("code",code); 
     } 
     } 

     /** 
     * Retrieves a JWT to identify the user without the 
     * regular client-side authorization flow. The jwt payload needs to be 
     * sent to the server-side component. 
     */ 
     public class RetrieveJwtAsyncTask 
      extends AsyncTask<Void, Boolean, String> { 

     @Override 
     protected String doInBackground(Void... params) { 
      String scope = "audience:server:client_id:" + CLIENT_ID; 
      try { 
      return GoogleAuthUtil.getToken(
        Signup.this, mCredential.getSelectedAccountName(), scope); 
      } catch(UserRecoverableAuthIOException e) { 
      startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); 
      } catch (Exception e) { 
      e.printStackTrace(); // TODO: handle the exception 
      } 
      return null; 
     } 

     @Override 
     protected void onPostExecute(String idToken) { 
      // exchange encrypted idToken with server-side to identify the user 
     // mIdTokenEditText.setText(idToken); 
      Log.d("idtoken",idToken); 
     } 
     } 

     private static final int REQUEST_ACCOUNT_PICKER = 100; 
     private static final int REQUEST_AUTHORIZATION = 200; 

    } 

मैं पूरी तरह से अनजान यहाँ क्या हो रहा है कर रहा हूँ। मदद?

+0

चूंकि GoogleAuthUtil.getToken() विधि ने GoogleAuthException को किसी ईमेल पर "BadUsername" संदेश के साथ फेंकना शुरू किया है, जो किसी डिवाइस पर पंजीकृत नहीं है, पिछले अपवाद के बजाय अवैध "अमान्य खाता 'ईमेल_ड्रेस'" संदेश के साथ अवैध अपवाद। http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html#getToken(android.content.Context, java.lang.String, java.lang.String) – toobsco42

उत्तर

1

मुझे भी इसी तरह की समस्या थी। मेरे मामले में समस्या Google कंसोल में मिस्ड एप्लिकेशन नाम में थी।

ओपन console अपनी परियोजना पर नेविगेट करें और "सहमति स्क्रीन" चुनें। "PRODUCT NAME" फ़ील्ड भरें और सहेजें।

0

CheatEx के समान, मुझे "सहमति स्क्रीन" पृष्ठ से अपना ईमेल पता चुनना और सहेजना पड़ा।

संबंधित मुद्दे