This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create Google Auth credentials to pass to Firebase | |
final GoogleAuthCredential googleAuthCredential = | |
GoogleAuthProvider.credential( | |
accessToken: googleAuth.accessToken, | |
idToken: googleAuth.idToken, | |
); | |
//Authenticate against Firebase with Google credentials | |
await firebaseAuth.signInWithCredential(googleAuthCredential).then((userCredential) => { | |
setState(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final GoogleSignInAuthentication googleAuth = await googleUser.authentication; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void signInWithGoogle() async { | |
final GoogleSignInAccount googleUser = await GoogleSignIn().signIn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void dispose() { | |
if (deepLinkSubscription != null) { | |
deepLinkSubscription.cancel(); | |
deepLinkSubscription = null; | |
} | |
super.dispose(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:http/http.dart' as http; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await firebaseAuth.signInWithCredential(credential).then((userCredentials) => { | |
setState(() { | |
user = userCredentials; | |
}) | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final AuthCredential credential = GithubAuthProvider.credential( | |
json.decode(response.body)['access_token'], | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loginWithGitHub(String code) async { | |
//Step 4 | |
final response = await http.post( | |
"https://github.com/login/oauth/access_token", | |
headers: { | |
"Content-Type": "application/json", | |
"Accept": "application/json" | |
}, | |
body: "{\"client_id\":\"" + CLIENT_ID | |
+ "\",\"client_secret\":\"" + CLIENT_SECRET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void initState() { | |
deepLinkSubscription = getLinksStream().listen((String link) { | |
String code = getCodeFromGitHubLink(link); | |
loginWithGitHub(code); | |
}, cancelOnError: true); | |
super.initState(); | |
} |
NewerOlder