Google Drive V3 API implementation Xamarin Android - 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.

Related

Android App Development: Account Credentials and Database Backup

I am new to Android app development and have a few questions.
Suppose I want to create an app that has user login. I want to authenticate the users over the internet. Where should I collect and store all the user accounts and their credential information? Will this storage be free or paid?
Can I integrate Google Sign-in in my app for free? Where should I store the google sign-in account information of all the users?
Is it possible to integrate Google sign-in and backup the app database (.db files etc.) and other user settings to the user's Google Drive (for later recovery when app is reinstalled)? Is this free or paid?
Answering Questions 1 and 2:
There are a few options:
1) Firebase:
If you only want to work on the mobile app, not on the backend software, the easiest way is Firebase.
Firebase has built-in support for Google authentication and you can follow the tutorials provided by Google here, and the samples here. (I`m using the link because the code is too big to paste here on the answer.) The authentication service is free.
2) Self implementation:
You can use Google sign in API on this example and implement the server side if you have a backend team or want to do it yourself.
About Question 3 (Google drive), users can use their own Google account to store applications backups, and you can select what application files will be stored. In this case, they will consume their free Google Drive quota, and thus the service will be Free.
Google provides an API for that, and you can have have a look on this example here. (Notice that Google had deprecated Google Drive Android API on December/2018. But the example on the link shows what you have to do on the newer way, using Drive REST API).
There are other approaches and solutions but I tried to give you the simplest and cheapest ones.

Does the Google Drive Android API work for all Google accounts?

I’m trying to save some user preferences across multiple devices on my Android application.
Do I need to request the user other authentication credentials or additional steps to enable the Google Drive Android API beside the Google account they already have?
Is Google Drive available for all Google accounts?

How could I allow users to access to my google cloud storage

I'm developing an android application.
In the android application, users read files from my google cloud storage and also update files to it, although it is not the main purpose of the application.
Now, I'm quite confused about how I allow users access to my google cloud storage.
Google recommends to use OAutn 2.0 authentication. So, I treid how it works on the following site.
https://developers.google.com/oauthplayground/
In the playground, I allowed the "oauthplayground" to access to my google cloud storage.
But I don't need this step because I always want to allow the android application to access to my google cloud storage.
After thinking, I had the idea to use the Authorization code for the android application to access to my google cloud storage.
But it was a bad idea because an Authorization code has the expiration time.
How I allow users to access to my google cloud storage in this case??
Please help me.
If privacy is not a concern, you could set the ACL on the bucket to public-write. If privacy is a concern, you can use the Signed URLs feature. You can find an example of using the Signed URLs feature in the storage-signedurls-python repository on GitHub.

2-Legged OAuth for Google Drive from Android?

Can I use Google Drive to upload images through an Android application. I also would not want the user to be involved in the process of authentication because all the images should be uploaded to a specific user's Drive only. I think this is only possible through a 2-legged OAuth but does a 2-legged OAuth exist for the Drive??
Thank YOu
2-legged OAuth does not exist on Google Drive. The nearest behaviour achievable is by using Service Accounts with impersonation. If you have a google apps domain, you can use Provisioning API to find the users of the domain and impersonate them progammatically

Can I use AccountManager to let users sign in with their Google account?

I'm creating an app that will need users to create an account. (Like Facebook or Twitter would require you to.)
BUT, since it's an Android app, should/can I let them sign in with their Google Account using AccountManager or some other service? It'd be very helpful if they could just sign in to their Google account and their settings and other options would be saved to that account.
Main questions summed up:
Is it possible to let a user just use their Google account in my app?
If so, do I use AccountManager to have them sign in and save account information/settings?
What are other options?
Yes, you can get users to log into their Google Services using their Google credentials, for example, I have an app on Google Tasks and I use the Android AccountManager to let users authenticate themselves using their Google account on the android device (No need for users to enter their password!)
There are some really good examples to get you started:
This is an in-depth look into how you can authenticate based on the users Android credentials, has an example of how things work and how the UI should be: http://www.finalconcept.com.au/article/view/android-account-manager-step-by-step-2
This is an example of getting AccountManager to work with a Google service like Google Tasks: https://developers.google.com/google-apps/tasks/oauth-and-tasks-on-android
The last example is using the same concept for accessing the Google Picasa service: http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager
The other options you have is to have users manually enter their username/password. For that you have to use a third party authentication API (like signpost for OAuth) for them to log in.
In my tasks/todo application I provide users both options to sign in, using their android credentials or using third party authentication for users that want to log in using some other account (an account which is not enabled on that device)
Let me know if you have more questions
Although it is a new development, Google Plus Sign-in introduced as part of Google Play Services can also be used. More info can be found at Android developers blog. See example implementation from Banjo app
There seems to be a big limitation - The user need to have Google+ app installed on the device to use this.
Also this is a pretty good blog if someone is interested in implementing the solution.
#Soham gave you some very useful links but he didn't correct one major error: AccountManager is the entity that manages the accounts on your Android device - it has nothing to do with your google account! you can use google account and create a NEW account on your device using the AccountManager.
The rest you can learn from the links Soham gave you.

Categories

Resources