8

I am integrating the Google Plus in my Android app. I have created the project in the Google API Console. I created the OAuth Client ID and I doubled check the package name and Keystore SHA1 but both are correct but I am still getting the Internal Error Occur.

I have seen many threads but mostly saying the related to SHA1 and package name which is correct here.

Guys share your views.


Edit : I have tested using the debug.keystore and custom created keystore but nothing worked for me.

setScopes("PLUS_LOGIN") also not helpful for me.


public class MainActivity extends Activity implements ConnectionCallbacks,
        OnConnectionFailedListener, OnClickListener {

    private static final int REQUEST_CODE_RESOLVE_ERR = 9000;

    private ProgressDialog mConnectionProgressDialog;
    private PlusClient mPlusClient;
    private ConnectionResult mConnectionResult;

    private static final String TAG = "Google Plus Demo";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mPlusClient = new PlusClient.Builder(this, this, this)
                .setActions("http://schemas.google.com/AddActivity",
                        "http://schemas.google.com/BuyActivity")
                .setScopes(Scopes.PLUS_LOGIN).build();

        // Progress Bar to be displayed if the connection failure is not
        // resolved.
        mConnectionProgressDialog = new ProgressDialog(this);
        mConnectionProgressDialog.setMessage("Signing in...");

        findViewById(R.id.sign_in_button).setOnClickListener(this);

    }

    @Override
    protected void onStart() {
        super.onStart();
        mPlusClient.connect();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mPlusClient.disconnect();
    }

    @Override
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
        if(requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
            mConnectionResult = null;
            mPlusClient.connect();
        }
    }

    @Override
    public void onConnectionFailed(ConnectionResult result) {
        if(mConnectionProgressDialog.isShowing()) {
            // The user clicked on the sign-in button already. Start to resolve
            // connection errors. Wait until onConnected() to dismiss the 
            // connection dialog.

            if(result.hasResolution()) {
                try {
                    result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                } catch(SendIntentException e) {
                    mPlusClient.connect();
                }
            }
        }

        // Save the result
        mConnectionResult = result;
    }

    @Override
    public void onConnected(Bundle connectionHint) {
        String accountName = mPlusClient.getAccountName();
        Toast.makeText(this, accountName, Toast.LENGTH_LONG).show();
        mConnectionProgressDialog.dismiss();
    }

    @Override
    public void onDisconnected() {
        Log.d(TAG, "Disconnected");
    }

    @Override
    public void onClick(View view) {
        if(view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
            if(mConnectionResult == null) {
                mConnectionProgressDialog.show();
            } else {
                try {
                    mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                } catch(SendIntentException e) {
                    // Try connecting again
                    mConnectionResult = null;
                    mPlusClient.connect();
                }
            }
        }
    }
}

Logs

01-27 20:22:23.871: I/GLSUser(1699): GLS error: INVALID_SCOPE xyz@gmail.com oauth2:PLUS_LOGIN
01-27 20:22:23.871: W/GLSActivity(1699): [aia] Status from wire: INVALID_SCOPE status: INVALID_SCOPE
01-27 20:22:23.965: W/InputManagerService(1536): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4076b580
01-27 20:22:24.020: I/eFrame(3180): pkgname_before:com.google.android.gms  class:com.xicom.appdemo.MainActivity
01-27 20:22:24.027: D/SurfaceFlinger(1536): Layer[34bee8]:: Tile format buffer w[256] h[64] f[1] v[0x47855000] p[0x97fd5000] sz[65536]
01-27 20:22:25.012: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0
01-27 20:22:25.012: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause
01-27 20:22:25.106: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep
01-27 20:22:27.684: W/PowerManagerService(1536): Timer 0x3->0x3|0x3
01-27 20:22:27.691: D/BatteryService(1536): update start

Code :

mPlusClient = new PlusClient.Builder(this, this, this)
    .setActions("http://schemas.google.com/AddActivity",
            "http://schemas.google.com/BuyActivity")
    .build();

Log second version

01-28 22:25:16.164: D/SurfaceFlinger(1536): Layer[37c9c0]:: Tile format buffer w[256] h[320] f[1] v[0x4ac99000] p[0x94741000] sz[327680]
01-28 22:25:17.007: D/SurfaceFlinger(1536): Layer[8a5a68] [4] non-RGB565 reloads
01-28 22:25:17.250: I/fno(2652): I/O exception (javax.net.ssl.SSLException) caught when processing request: Write error: ssl=0x25d728: I/O error during system call, Broken pipe
01-28 22:25:17.250: I/fno(2652): Retrying request
01-28 22:25:18.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads
01-28 22:25:18.101: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0
01-28 22:25:18.101: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause
01-28 22:25:18.187: D/BatteryService(1536): update start
01-28 22:25:18.195: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep
01-28 22:25:19.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null
01-28 22:25:19.484: I/GLSUser(2652): GLS error: INVALID_CLIENT_ID xyz@gmail.com oauth2:https://www.googleapis.com/auth/plus.login
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: Unknown status: UNKNOWN
01-28 22:25:19.570: D/dalvikvm(20673): GC_EXTERNAL_ALLOC freed 163K, 43% free 3397K/5959K, external 511K/517K, paused 47ms
01-28 22:25:19.664: W/InputManagerService(1536): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40605c00
01-28 22:25:19.781: D/SurfaceFlinger(1536): Layer[278dc0]:: Tile format buffer w[256] h[64] f[1] v[0x49520000] p[0x97fcc000] sz[65536]
01-28 22:25:19.835: I/eFrame(20257): pkgname_before:com.google.android.gms  class:com.xicom.appdemo.MainActivity
01-28 22:25:20.046: D/dalvikvm(20257): GC_CONCURRENT freed 384K, 49% free 3021K/5895K, external 412K/517K, paused 4ms+6ms
01-28 22:25:20.757: W/PowerManagerService(1536): Timer 0x3->0x3|0x3
01-28 22:25:23.203: D/BatteryService(1536): update start
android
  • 3,261
  • 3
  • 16
  • 18
  • possible duplicate of ["An internal error occurred" with integration of Google Plus Login](http://stackoverflow.com/questions/15762904/an-internal-error-occurred-with-integration-of-google-plus-login) – bummi Sep 13 '14 at 09:02
  • I got the same error. It occurs when request email from google sign in client. – Choxmi Jan 22 '16 at 07:29

4 Answers4

45

I had the same problem, and I solved it looking around in the Developer Console.

Turns out that you need to fill in the necessary information about your project for the consent screen.

Solution:

Choose your email and insert your project name. Next time you launch your application you will have the proper consent screen and thereafter all will work fine.

Stephan
  • 1,858
  • 2
  • 25
  • 46
  • poor Google poor documentation – Muhammad Babar Sep 15 '14 at 07:39
  • Thanks a lot buddy... how you people get solution for this kind of questions? can u tell me if you don't mind. – Mohammed mansoor Sep 25 '14 at 04:12
  • Ah! that's not documented! Bug incoming in 3, 2, 1, https://code.google.com/p/android/issues/detail?id=78145 – Daniele Segato Oct 24 '14 at 15:58
  • If you have already set your SHA1 fingerprint (debug or release) in your google developer console and you still having this problem, check if you effectively build with your key, here is the way to set the key in Android Studio: http://stackoverflow.com/a/17992232/2486332 – quent Mar 22 '16 at 20:25
2

Do you get any output in logcat to go with the error? Try enabling verbose logging if you haven't (see https://developers.google.com/+/mobile/android/getting-started#frequently_asked_questions)

adb shell setprop log.tag.GooglePlusPlatform VERBOSE

Edit: Thanks for adding the logs. The GLS error is the interesting one there:

I/GLSUser(1699): GLS error: INVALID_SCOPE xyz@gmail.com oauth2:PLUS_LOGIN

Can you check that you have enabled the Google+ API in your API console project, and can you also try removing the setScopes line entirely (PLUS_LOGIN will be the default, so that seems the easiest way to test if anything interesting is going on).

I'm not sure off the top of my head whether PLUS_LOGIN being in their is indicative of a replace not happening, or its just the logging looks like that, but remove the line should remove it from the equation.

EDIT - based on your updated dump the scope now looks good but there is an invalid client Id error in there. Make sure there aren't any trailing spaces around your sha 1 in the client Id and that the package name exactly matches. Also try clearing the cache in google play service (clear data from the menu in the google settings app).

Ian Barber
  • 19,765
  • 3
  • 58
  • 58
  • I have added the second log also which I am getting now and added the line also in the question also which you suggested to try but still not working. Hope to hear from you soon!! – android Jan 28 '14 at 16:58
  • Replied again - looks like an invalid client id error in there. Suggested clearing play service cache and rechecking for spaces etc in packagename or sha1 on the api console. You can also check your apk to make sure its the signing key you expect. – Ian Barber Jan 29 '14 at 22:08
  • 1
    All are right : package name is correct and sha1 is also correct. There is no space between any of these and I tried clearing the cache in Google Play Service and still same issue. Hope to hear from you soon! – android Jan 30 '14 at 17:34
0

you must fill the "Consent Screen", nothing else works if you do not fill the content in "Consent Screen".

Naveen
  • 830
  • 9
  • 19
0

In my case, it took some time to see the consent screen. After making changes to the api console its better to wait 5-10 minutes and then try login process.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61