Skip to content

Commit

Permalink
Merge pull request #31 from Ryuuhj/feat/구글로그인-#28
Browse files Browse the repository at this point in the history
[feat] 구글 로그인 연동 #28
  • Loading branch information
Ryuuhj authored Mar 15, 2023
2 parents 6b1c592 + 3017919 commit f9dc41a
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 7 deletions.
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
*.jks
21 changes: 19 additions & 2 deletions frontend/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

/*def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}*/

android {
compileSdkVersion 32
compileSdkVersion 33
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -48,10 +54,20 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 20
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
/*
signingConfigs{
debug{
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('mykey.jks')
storePassword 'android'
}
}*/

buildTypes {
release {
Expand All @@ -68,4 +84,5 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
1 change: 1 addition & 0 deletions frontend/android/app/google-service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installed":{"client_id":"907385257015-oq67gn993s9ss1hfne6tfedohkangtoc.apps.googleusercontent.com","project_id":"heroic-habitat-376713","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
14 changes: 14 additions & 0 deletions frontend/ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>907385257015-aul7p80r62ileso12clfps43v9bbbr0s.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.907385257015-aul7p80r62ileso12clfps43v9bbbr0s</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.leturn</string>
</dict>
</plist>
10 changes: 10 additions & 0 deletions frontend/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<!-- google login -->
<string>com.googleusercontent.apps.907385257015-aul7p80r62ileso12clfps43v9bbbr0s</string>
</array>
</dict>
</array>
<key>CFBundleName</key>
<string>leturn</string>
<key>CFBundlePackageType</key>
Expand Down
53 changes: 49 additions & 4 deletions frontend/lib/screens/home_screen/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:leturn/api/google_signin_api.dart';
import 'package:leturn/const/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:http/http.dart' as http;
import 'package:leturn/screens/page_view.dart';
import 'package:leturn/screens/login/login_page.dart';
import 'package:leturn/screens/user_folder.dart';

import '../../const/Server.dart';

var token;

class HomeScreen extends StatelessWidget{
const HomeScreen({Key? key}) : super(key: key);
Expand Down Expand Up @@ -90,10 +99,11 @@ class _Buttons extends StatelessWidget{
)
],
),
onPressed: (){
/* Navigator.push(context,
MaterialPageRoute(
builder: (_) => _PageView().createState()));*/
onPressed: () async {
//bool result = nextPage();
if(await nextPage()) {
Navigator.push(context, MaterialPageRoute(builder: (context) => FolderPage()));
}
},
),
),
Expand Down Expand Up @@ -138,4 +148,39 @@ class _Buttons extends StatelessWidget{
),
);
}

Future signIn() async{
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;

if(googleAuth == null) {
print("google login error >>> googleAuth is null");
}else{
String url = '$serverHttp/login/google';
//final req = jsonEncode(<String,String>{'access_token':googleAuth!.accessToken.toString()});
final req = jsonEncode(<String,String>{'access_token':'accessToken'});

http.Response response = await http.post(Uri.parse(url),body: req);

if(response.statusCode == 200){
token = jsonDecode(response.body)["token"];
print("token : $token");
//저장소에 토큰 저장
}else{
print(response.statusCode.toString());
}
}

}

Future<bool> nextPage() async{
await signIn();
if(token == null){
return false;
}else{
return true;
}
}


}
44 changes: 43 additions & 1 deletion frontend/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,41 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
google_sign_in:
dependency: "direct main"
description:
name: google_sign_in
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.4"
google_sign_in_android:
dependency: transitive
description:
name: google_sign_in_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.8"
google_sign_in_ios:
dependency: transitive
description:
name: google_sign_in_ios
url: "https://pub.dartlang.org"
source: hosted
version: "5.6.1"
google_sign_in_platform_interface:
dependency: transitive
description:
name: google_sign_in_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
google_sign_in_web:
dependency: transitive
description:
name: google_sign_in_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.2+1"
http:
dependency: "direct main"
description:
Expand Down Expand Up @@ -308,6 +343,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.1"
rxdart:
dependency: transitive
description:
Expand Down Expand Up @@ -406,4 +448,4 @@ packages:
version: "6.1.0"
sdks:
dart: ">=2.18.2 <3.0.0"
flutter: ">=3.0.0"
flutter: ">=3.3.0"
1 change: 1 addition & 0 deletions frontend/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
http: ^0.13.5
card_swiper : ^2.0.1
logger: ^1.2.2
google_sign_in: ^5.4.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit f9dc41a

Please sign in to comment.