KyleKun / one_second_diary

Minimalist video diary app.
MIT License
296 stars 60 forks source link

Optional Google Login / Drive Backup #29

Open KyleKun opened 1 year ago

KyleKun commented 1 year ago

@Amorenew

ishanvaghani commented 9 months ago

@KyleKun I want to start on this; can you please elaborate on this?

KyleKun commented 9 months ago

@KyleKun I want to start on this; can you please elaborate on this?

In settings page, there's a backup tutorial button. This should become a backup feature instead, redirect to login with Google account and then sync the folder OneSecondDiary (inside DCIM) with Drive / Google Photos.

alexanderadam commented 9 months ago

And please remember not to use proprietary libraries. Otherwise F-Droid inclusion won't be allowed any more.

KyleKun commented 9 months ago

And please remember not to use proprietary libraries. Otherwise F-Droid inclusion won't be allowed any more.

But in case it is unavoidable, we can keep a variant without it for f-droid.

alexanderadam commented 9 months ago

Sure, then the PR should allow a build condition to disable a build with the proprietary library. 👍

ishanvaghani commented 9 months ago

We need to use Google Auth APIs and Drive APIs.

alexanderadam commented 9 months ago

We need to use Google Auth APIs and Drive APIs.

Using an API isn't a problem here. Using certain APIs might just be shown as a warning on F-Droid. But using a proprietary library will exclude the app from being published.

Right now I'm using Round Sync (which also supports Google Drive and other clouds for backing up btw) for automatic backups of One Second Diary clips. Round Sync is a fork of RCX and uses the free Rclone sync library.

And because it uses only free components, both apps can be published on F-Droid (RCX and Round Sync).

ishanvaghani commented 9 months ago

User will need Round Sync app in this case. So it's dependency of the other app.

amorenew commented 9 months ago

@alexanderadam We could just use HTTP calls so we don't get warnings

Using certain APIs might just be shown as a warning on F-Droid. But using a proprietary library will exclude the app from being published.

amorenew commented 9 months ago
how to use Google login in Flutter without a library? import 'package:http/http.dart' as http; import 'dart:convert'; import 'dart:typed_data'; Future signInWithGoogle() async { // Define your Client ID and other configurations String clientId = 'YOUR_CLIENT_ID'; String redirectUri = 'YOUR_REDIRECT_URI'; String scopes = 'openid email https://www.googleapis.com/auth/drive.file'; // Include the Drive file scope // Create the authorization URL String authUrl = 'https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=$clientId&redirect_uri=$redirectUri&scope=$scopes'; // Open a webview or use url_launcher to open authUrl in a browser // Capture the response after successful login and extract the authorization code // Exchange the authorization code for an access token // Construct the POST request String tokenUrl = 'https://oauth2.googleapis.com/token'; String code = 'YOUR_AUTHORIZATION_CODE'; Map body = { 'code': code, 'client_id': clientId, 'client_secret': 'YOUR_CLIENT_SECRET', 'redirect_uri': redirectUri, 'grant_type': 'authorization_code', }; // Send POST request to exchange code for access token http.Response response = await http.post(Uri.parse(tokenUrl), headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: body); // Parse the response to get access token if (response.statusCode == 200) { Map tokenData = json.decode(response.body); String accessToken = tokenData['access_token']; // You can use this access token to make requests to Google APIs } else { // Handle error } }
how to use google drive in Flutter without a library? import 'dart:convert'; import 'package:http/http.dart' as http; Future uploadToDrive(String accessToken) async { String uploadUrl = 'https://www.googleapis.com/upload/drive/v3/files?uploadType=media'; // File content to be uploaded String fileContent = 'Hello, this is a test file content!'; // Create the HTTP request to upload the file http.Response response = await http.post( Uri.parse(uploadUrl), headers: { 'Authorization': 'Bearer $accessToken', 'Content-Type': 'text/plain', // Change content type based on your file type }, body: utf8.encode(fileContent), ); if (response.statusCode == 200) { print('File uploaded successfully!'); // Handle success } else { print('File upload failed: ${response.body}'); // Handle error } }