Skip to content

Instantly share code, notes, and snippets.

@alexastrum
Forked from ptruiz/firebase-auth-2-step-4.dart
Last active October 15, 2020 15:11
Show Gist options
  • Save alexastrum/ae009e6add41f08d85c662716e934e2f to your computer and use it in GitHub Desktop.
Save alexastrum/ae009e6add41f08d85c662716e934e2f to your computer and use it in GitHub Desktop.
@override
void initState() {
deepLinkSubscription = getLinksStream().listen((String link) {
loginWithGitHub(link);
}, cancelOnError: true);
super.initState();
}
//...
void loginWithGitHub(String link) async {
//Step 4
final response = await http.post(
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=" + FIREBASE_API_KEY,
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: "{\"requestUri\":\"" + link
+ "\"}",
);
final AuthCredential credential = GithubAuthProvider.credential(
json.decode(response.body)['oauthAccessToken'],
);
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment