Skip to content

Instantly share code, notes, and snippets.

//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(() => {
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
void signInWithGoogle() async {
final GoogleSignInAccount googleUser = await GoogleSignIn().signIn();
FlatButton(onPressed: () {signInWithGoogle();}, child: Text("Sign In With Google")),
@override
void dispose() {
if (deepLinkSubscription != null) {
deepLinkSubscription.cancel();
deepLinkSubscription = null;
}
super.dispose();
}
import 'package:http/http.dart' as http;
await firebaseAuth.signInWithCredential(credential).then((userCredentials) => {
setState(() {
user = userCredentials;
})
});
}
final AuthCredential credential = GithubAuthProvider.credential(
json.decode(response.body)['access_token'],
);
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
@override
void initState() {
deepLinkSubscription = getLinksStream().listen((String link) {
String code = getCodeFromGitHubLink(link);
loginWithGitHub(code);
}, cancelOnError: true);
super.initState();
}