Accessing google drive in android - android

I am making and android app which downloads a particular file from Google Drive, reformats the data in the file and then displays it to the user.I have used the Google Drive API. In the app, instead of asking the User to select an account, I want to hard code a Google Account Username and Password through which the file on the Drive is downloaded. This should happen without the user's interaction.

You do not need to hardcode your account data - just use Service account
How to use Google Drive SDK in Android project with hardcoded credentials - here the solution.

Related

Google Drive V3 API implementation Xamarin Android

I've been trying for a while now to create an application where the users can sign in with their Google Account and the application will automatically upload some files into the users google drive.
So far I've managed to implement the Sign In mechanism but for the Google Drive integration I'm kind of confused if I should use a Service Account or not.
I've found this solution here Google Drive API implementation Xamarin Android but this way too old, and I can't find any updated solutions.
If anyone knows any solution or any suggestion I will appreciate it.
Think of serive accounts as a dummy user, this user can then be preauthorized to access some data.
You could share a folder on google drive with a service account and then the service account would have access to that folder on google drive.
Service accounts are intended for use by developers to access data they control.
If you are going to access the users account then you will need to use Oauth2, and request consent of the user to access their google drive account.
Unforuantatly it appears that Google Drive Android API used in the question you have linked is deprcated.
I can also tell you that the Google .net client library does not support Xamarin authorization.

How to hardcode a Google Account in Android?

So, I was using the Google Drive API in one of my applications and when the application starts it asks for Google Sign in and I have to sign in using the Google Account on which Drive API is enabled.
So then I can upload any file using my app to the drive.
But I wondered if I could sign in to that particular Google Account through the code itself, by putting the credentials inside the code.
So when I open the application it should automatically sign in to that Account which has Drive API enabled and then the Application can be used to upload any files to that particular drive.
Is this possible?
You actually do not need to hard code. First, you may check if you have an already signed in user by using this line of code:
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
If you already have one you pass the info of this user without even needing to sign in again. Or, there is another way called silent sign-in.
GoogleSignIn.silentSignIn()
With a silent sign in you won't be asked for credentials every time, once you sign in successfully. More info can be found here.

How to upload and retrieve the files from Google drive with static credentials android

I have the requirement of saving files to google drive of Admin account and then retrieving. Now i am able to upload the files to Users google drive account which is in his phone, i am not able to give static credentials of my drive. Is there any Possibility?Please give the reference of giving static credentials to the google drive to save and retrieve the files.
First, be aware of the security implications of embedding static credentials. As a minimum, use only drive.file scope, so the credentials only allow access to files created by the app.
The "static credential" you are referring to is a Refresh Token. You will use this to fetch an Access Token whenever your app needs to access GDrive. This answer How do I authorise an app (web or installed) without user intervention? (canonical ?) describes the detailed steps to follow.
You should also consider using a Service Account instead of a regular account for the app's storage.

Using google drive API to access my own "public" folder android/iOS

I have a google drive account that i want people within a certain organization to be able to upload files to programmatically, and also as invisible as possible. as i'm following along the google drive SDK tutorials, i can't seem to find anything about uploading a file directly to MY drive account. all the tutorials seem to be talking about allowing users to upload a file to their own account. The other problem is that they seem to all require some user permission (which i don't want).
the idea is this -> there's about 100 ppl (very controlled on who gets access) that have a special build of an android/iOS build, and for these people, i want to periodically sample certain screenshots of how they use the app. i'm able to save the screenshot files to their device locally; however, i want a "semi-public" source of viewing on these files. so i've set up a google drive account so that i can accept these screenshots in to my account. however, i don't want the users to have to accept any permissions, or use their own account. Ideally, at the end, i can share my drive account folder (with these screenshots) with people that i select to share it with.
Is this even possible? If so, how do i do this?
The Drive API for Android only supports authorizing the current user, however if you use the Google APIs Java client instead to access the Drive API you can store credentials for your account with the application and use those for all users of your app. Read more about authorization and the Java client here.

Upload file to unique google drive account in android

I need to build an application which upload the photo taken through the application to a unique google drive account.Have tried https://developers.google.com/drive/quickstart-android and build the app .But it is taking the google account which has been registered in the tablet,wheras i want to upload it to a unique account.Can someone help me on the same.
You should use Service Accounts to store files on behalf of your application and not on a user’s Drive: https://developers.google.com/drive/service-accounts

Categories

Resources