I have an android app that manages users via Firebase platform (preforms sign-in with google account). After a successful login I have a FirebaseAuth instance which from it I can gain access to the FirebaseUser instance.
Now I want to access the logged-in user Google Sheets and manipulated them (read, write, create a new one). How can I do that?
pseudo-code:
FirebaseAuth mAuth;
.....
// sign-in with google...
.....
if(mAuth.getCurrentUser() != null){
// Here for example I want to read the titles of all this user sheets
}
I read this thread, but still didn't understand how to use my FirebaseUser in order to access SheetsAPI. I don't need the code for actually reading or writing sheets, only how to create the com.google.api.services.sheets.v4.Sheets instance.
I added the required dependencies to the build.gradle and have the clientID and clientsecret from the Google API Console, but I don't know how to use them.
Edit:
I also read this thread but it didn't help me because I don't use GoogleSignIn. Here is a snippet of my authentication process:
// create the intent for sign in
// in MainActivity
startActivityForResult(
viewModel.generateAuthenticationIntent(),
RC_SIGN_IN);
// in viewModel:
public Intent generateAuthenticationIntent() {
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build());
return AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.setIsSmartLockEnabled(false)
.build();
}
// MainActivity:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
viewModel.authenticate();
createHome();
} else {
Log.d(
TAG,
String.format(
"%s\n"+
"response.getError().getErrorCode()=%d\n"+
"response.getError().getMessage()=%s"
,
response.getError().getErrorCode(),
response.getError().getMessage()
)
);
}
}
}
Any help will be appreciated.
This question is absurd, because using Google as authentication provider does not imply one actually logs in to Google. This won't work and you need to login into the Google account before able to access anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With