I am developing an app where the user should authorize access to ones Google Account. Then, I am planning to store the auth_token in firestore so that later I can run a cloud function to send them a newsletter with data from google calendar (and some enrichments, but not relevant here).
I set up the Google API from the console and try to establish a connection with this Custom Action:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:google_sign_in/google_sign_in.dart';
Future<String?> signInWithGoogle() async {
try {
final GoogleSignIn googleSignIn = GoogleSignIn(
clientId:
'...',
scopes: <String>['https://www.googleapis.com/auth/calendar.events'],
);
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount!.authentication;
debugPrint(googleSignInAuthentication.accessToken);
return googleSignInAuthentication.accessToken;
} catch (error) {
return "error";
}
}
The authorization window correctly pops up but in the end I get this error:
The OAuth token was not passed to gapi.client, since the gapi.client library is not loaded in your page.