mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-31 11:54:30 +01:00
Implement Redirect Authentication for Google and GitHub Sign-In (#5515)
This commit is contained in:
@@ -7,31 +7,24 @@ class AuthService {
|
||||
clientId:
|
||||
"387936576242-iejdacrjljds7hf99q0p6eqna8rju3sb.apps.googleusercontent.com");
|
||||
|
||||
// Sign in with Google
|
||||
// Sign in with Google using redirect
|
||||
Future<UserCredential?> signInWithGoogle() async {
|
||||
try {
|
||||
final GoogleSignInAccount? googleSignInAccount =
|
||||
await googleSignIn.signIn();
|
||||
if (googleSignInAccount != null) {
|
||||
final GoogleSignInAuthentication googleSignInAuthentication =
|
||||
await googleSignInAccount.authentication;
|
||||
final AuthCredential credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleSignInAuthentication.accessToken,
|
||||
idToken: googleSignInAuthentication.idToken,
|
||||
);
|
||||
return await _auth.signInWithCredential(credential);
|
||||
}
|
||||
final GoogleAuthProvider googleProvider = GoogleAuthProvider();
|
||||
await _auth.signInWithRedirect(googleProvider);
|
||||
return await _auth.getRedirectResult();
|
||||
} catch (e) {
|
||||
print("Error during Google Sign-In: $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Sign in with GitHub
|
||||
// Sign in with GitHub using redirect
|
||||
Future<UserCredential?> signInWithGitHub() async {
|
||||
try {
|
||||
final GithubAuthProvider provider = GithubAuthProvider();
|
||||
return await _auth.signInWithPopup(provider);
|
||||
final GithubAuthProvider githubProvider = GithubAuthProvider();
|
||||
await _auth.signInWithRedirect(githubProvider);
|
||||
return await _auth.getRedirectResult();
|
||||
} catch (e) {
|
||||
print("Error during GitHub Sign-In: $e");
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user