Android-quick start app with google drive is not working - google-drive-android-api

I am trying to upload an image using quick start tutorial to google drive initially my app starts and asks to choose account but when I select an account it keeps asking again and again.

As shown in the code, no account name is passed. Try setting useDefaultAccount() method which will specify that the default account should be used when connecting to services. Otherwise, use clearDefaultAccountAndReconnect() method if you prefer setting up multiple accounts. This method will clear the account selected and will prompt the user to pick an account before reconnecting.
See GoogleApiClient for more information regarding sign_in.
In addition to that, see also installation and configuration of the Google Play services SDK regarding creation of credentials.
If you haven't done so, check credentials created for your project. Here are the steps:
Open the Credentials page in the API Console.
Follow these steps if your application needs to submit authorized
requests:
a. Click Create credentials > OAuth client ID.
b. Select Android.
c. In the Package name field, enter your Android app's package name.
d. Paste the SHA1 fingerprint into the form where requested.
e. Click Create.
Otherwise, follow the steps below, which are for applications that only need to make unauthorized API calls:
a. Click Create credentials > API key.
b. Select Android key.
c. Paste the SHA1 fingerprint into the form where requested.
d. Type your Android app's package name into the form where requested.
e. Click Create.

Related

Auto Read OTP in flutter using firebase is possible?

I have same problem and search a lot . But can't find exact Solution.
But I solve this problem by enabling 'Android Device Verification' API
Steps:
1:Go to the Library page in the Google APIs Console.
2:Search for, and select, the Android Device Verification API. The Android Device Verification API dashboard screen appears.
3:If the API isn't already enabled, click Enable.
4:If the Create credentials button appears, click on it to generate an API key. Otherwise, click the All API credentials drop-down list, then select the API key that's associated with your project that has enabled the Android Device Verification API.
Check this link for more information
https://developer.android.com/training/safetynet/attestation?authuser=0
The following package helps for auto reading of OTP
sms_autofill
https://pub.dev/packages/sms_autofill
This is a Similar issue for android mentioned, and Below are few work around:
You need to make sure the message you receive contains the hash of your app. Below is the right format :
123456 is your verification code for %APP_NAME%.
abc_hascode_xyz
If your SMS does not contain the hashCode at the end, you might have to shorten your app name to not more than 15 characters.
If your app is already published on Google Play, the name in the SMS will be the same as the one in the Google play store.
If you changed the name to 15 characters and the error still persists, you might have to wait for at least 24hours for the change to reflect on firebase.
if after all above it's still not resolved, please check if your receiver is well configured in the code.
check out the new GooglePlay policy on app name : Examples of common app names violations
Firebase auth with the phone automatically detects OTP in the phone itself.
But in few cases, OTP is not fetched by itself so I would like to suggest you please make a template such that OTP automatically gets detected.

What a client has to enable to use my app to edit their Google Sheet

Let's say I wrote a simple desktop app that reads some data from a Google Sheet, goes off and finds the answer and comes back and writes it into the Google Sheet. Now hundreds of people have sheets and want to use my program to process them. I post my program and let them download it for free.
Here is the sequence I think the end user needs to follow to get it to work:
1. Go to the GCP console and create a new project
2. Enable the Google Drive and Google Sheets APIs
3. Create a credentials JSON file with access as the Project Editor.
4. Create the Sheet if needed.
5. Copy the email out of the JSON file and Share it in the Sheet.
6. Make sure the JSON file is named right and in the right directory so the app finds it.
That all seems like a lot just so an app can read and write to a Google Sheet. Is there a simpler interface I am missing?
Answer:
There are steps that will always need to be completed when a user runs an application that accesses the Google APIs as themself, however depending on the case some of these may be simplified or circumvented.
More information:
There are a few things that you will need to bear in mind when creating an application for others to use, I'll summarise these points here and explain in a bit further detail:
To use a G Suite API, a Google Cloud Platform (GCP) Project needs to be owned and have the API associated.
In order to use the Google APIs (such as Drive and Sheets) its use must be enabled within the project that will use it.
If a user is running an application as themself, they will need to authenticate the application with their own credentials.
As per Google's documentation for Setting up a project:
Every application that uses Google APIs needs an associated Google Cloud Platform project. This project is a set of configuration settings that define how your application interacts with Google services and what resources it can use.
Resultantly, if your users will be running the application themselves, from a version of the app which is unpublished and not in the G Suite Marketplace then yes - they will need to create a GCP project, enable the respective APIs and use their personal credential file to run your application.
In reality this isn't the way G Suite Applications should be created, distributed and maintained and I can't reccommend that you do it this way. The G Suite marketplace is there to put in place a way of application distribution while removing the need for each user to create a GCP project and authenticate.
Things you can do:
With this in mind, there are a couple of things you can do to which will make the process of what you're doing slightly easier/shorter. Please bear in mind this isn't recommended for application distribution and more for testing purposes:
You can combine points 1, 2 and 3 in your question by having users click the Enable the Google Sheets API button on the Python Quickstart page. This button creates a new GCP project, enables the API and gives a credential file download link in one fell swoop.
Rather than having the user create the sheet themselves, you can code a sheet existence check in your program and create it if it doesn't already exist:
from pprint import pprint
from googleapiclient import discovery
# assuming you already have all your authentication code
sheetsService = discovery.build("sheets", "v4", credentials = credentials)
# add request body to variable sheetBody:
sheetBody = {}
# create the sheet:
sheetsService.spreadsheets().create(body = sheetBody).execute()
The https://www.googleapis.com/auth/drive.file scope allows your application to only access files created by itself which gives your application an extra level of security and trust.
In the sheetBody contents you can imclude the email address of the account running the application, if applicable, by running a Files: list request of the Drive API and reading the owners.emailAddress property of the response, to save reading the address from the JSON file.
References:
G Suite Developer:
G Suite APIs
Set Up Your Project
Build your app
Google Sheets API v4:
Python Quickstart
Google Drive API v3:
Files resource

GMail API - authorising a second email account

I am developing an app using VB.Net for accessing my GMail accounts. I was able to follow the steps given at .Net Quickstart and was able to able access one of my accounts. So whenever I run my app, it accesses my first gmail account automatically, which is fine. Now I would like to access my other gmail account using the same app. How to change the gmail account that is automatically accessed by my desktop app?
This is similar to this question, but I am not able to understand the answer provided there
Thanks in advance for your answers
Before using your app, you need to log out of the default gmail account (i.e., first gmail account in your case). So I think you need to log out from that first gmail account, then log in with the second gmail account and try to sign in from your app. Hope this helps!
Finally I found out where the authorization information is stored. It is stored in Environment.SpecialFolder.ApplicationData folder. A folder named Google.Apis.Auth is created under this folder and a new file with the authorization information is created under it (in my case it is C:\Users\myWindowsUserName\AppData\Roaming\Google.Apis.Auth). I deleted the file which was there, which had the token for my first gmail ID. When I ran my app again, it asked for user login and consent once again, at which point I provided details of my second gmail account. This pearl is available here

Google Drive Android: Error signing in the specified account. Please choose a different account

I am implementing the google drive use google play services.
I enable drive Api and Drive SDK from api console, and implemented configuration settings for Drive SDK, But when I try to login from my application, I get the following error,
Error signing in the specified account. Please choose a different account,
I add another account but facing the same error,
I did not know what is the problem? did I have to add the test users? but I did not find any place to test users.
In authentication section (https://developers.google.com/drive/web/enable-sdk#drive_integration). I found . In order to authenticate Drive users with the user info service, you must manually enter the following two scopes:
email
profile
But scope section only allow to enter the url and not the email and profile.
In the Google Developers Console, the package name must be the same as the Android app's package name in your android studio.
If you enter the wrong name, you may get this error message.

OneDrive Authentication & Shared URL access

Couple of questions:
I implemented the authentication process with OneDrive. My desktop application is designed for end-users. Every time the application is launched the little browser window pops up asking the user to confirm access...and if more than 1 hour passed user needs to provide username and password. Is there any way that end-user with SOME SORT of saved credentials (or user Code +user Secret, or API code + API secret) will be able to invoke the application and not be prompted by browser form (that currently requires login - if access token expired - or confirmation)?
The goal of my application is file sharing - that is, one end user may send URL (to the file that he uploaded to OneDrive) to another user and the latter should be able to download the file by clicking on the link (without any prompts, exactly like in manual process of sharing link to the file in OneDrive). Is it possible? If yes, how to achieve that? That is, how do I get that URL? Redandent to say that I am looking for a programmatic way to obtain a URL that will achieve the above described)
The OneDrive authentication process uses Microsoft account, which supports OAuth 2.0. You should be able to point the user to:
https://login.live.com/oauth20_authorize.srf?client_id=CLIENT_ID&scope=SCOPE&response_type=code&redirect_uri=REDIRECT_URI
Once the user authenticated and authorizes your app, the user will be taken to REDIRECT_URI/?code=CODE, where your app can exchange that code for an access token at:
https://login.live.com/oauth20_token.srf?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&code=CODE&grant_type=authorization_code&redirect_uri=REDIRECT_URI.
There are more details at http://onedrive.github.io/auth/msa_oauth.htm.