I am trying to use google drive API with flutter, testing on an android real device. I followed some youtube videos and medium blogs, i couldn't get it working.If there is any tutorial that you know, please post here.
I am currently using these packages googleapis: ^7.0.0, googleapis_auth: ^1.3.0.
I am stuck with an error that says about redirect_uri
This is a part of the code
import 'dart:io';
import 'package:google_drive_upload/helpers/constants.dart';
import 'package:googleapis/drive/v3.dart' as gdrive;
import 'package:googleapis_auth/auth_io.dart';
import 'package:url_launcher/url_launcher.dart';
class DriveService {
List<String> _scopes = [gdrive.DriveApi.driveScope];
getHttpClient() async {
return await clientViaUserConsent(ClientId(clientId), _scopes, prompt);
}
prompt(String url) {
launch(url);
}
upload(File file) async {
var client = await getHttpClient();
var drive = gdrive.DriveApi(client);
var res = await drive.files.create(
gdrive.File(),
uploadMedia: gdrive.Media(file.openRead(), file.lengthSync()),
);
print('Response here ${res.toJson()}');
}
}
I couldn't find redirect_uri in Oauth client in Oauth credentials for android (its available for web clients though).
Please help me to resolve this, been stuck here since 2 days :(
Edit 1 Tried with new fresh app with comoletely random appname so android domain won't clash, still same result.
