I\'m trying to connect my app to Google play service to access Google Drive but It showing me connection failed with statusCode SIGN_IN_REQUIRED.
Here is the info for the error you are receiving. I assume you are, but you need to be signed in to access Drive. When I run the sample app, at the very beginning it asks me to choose an account. Perhaps you do not have an account synced with the device you are using? There is an option to "add account", but maybe the behaviour is different when you have zero accounts. The documentation suggests that you either continue without using the API (simply because you cannot unless you sign in) or call startResolutionForResult(Activity, int) to prompt the user to sign in, but it would probably be easiest to just add the account to your device.
This will work once you have created your Google API project, you have added your SHA-1 and Package Name as asked. Also, keep in mind that your package must not conflict with other projects in Google. Hope this works. Register your project in :
Click here to add enable your Google api
and enable API once project credentials are all set. And if you are looking to upload or download your files then you have to use Permissions in your Manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-Surajit. Happy Coding.
Well i got the messages displayed in the LogCat:
GoogleApiClient onConnectionFailed with statusCode=SIGN_IN_REQUIRED
Sign in required means that we need to enable the Google Drive API https://console.developers.google.com
Download the client_id.json
file and add into the /app
folder of our project:
Then we can access with no problem, to get our expected API client connected.
:
For a better use of Google Drive API, this permissions are suggested:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
You can find a complete example here:
https://github.com/Jorgesys/Android-Google-Drive
As I see most of the answer above are right, still if you could not able to solve the problem. Here are the things please check with your development environment
If you have switched between two different systems(pc/laptop), please generate another SHA1 key for each system and update on Google developer console
If you have not switched between two system still you face the issue then, make sure in your manifest application Id is matching with package name you have given in Google developer console
Don't forget to enable Drive API in Google developer console
i have same problem and spent a lot of time to fix
maybe you didn't add your email to testers list on google console or maybe your device google play games app signed in with another account so add it to testers accounts and try again
https://play.google.com/apps/publish
Game Services -> Testing.
This error indicates that the account is locked, possibly for security reasons. You should go to drive.google.com from a desktop browser and log into the account before attempting to programmatically access the account via an Android app. Once you've gone all the way through a desktop browser login you should then be able to access the account from Android.