Skip to content

Commit 57ffbcb

Browse files
committed
chore(demo): add github & yahoo auth examples
1 parent 7af0baf commit 57ffbcb

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

apps/demo/src/plugin-demos/firebase-auth.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,45 @@ export class DemoModel extends DemoSharedFirebaseAuth {
2828
});
2929
}
3030

31+
async linkGithub() {
32+
if (!this.user) {
33+
return;
34+
}
35+
const provider = new OAuthProvider('github.com');
36+
provider.addCustomParameter('allow_signup', 'false');
37+
provider.setScopes(['user:email']);
38+
39+
firebase()
40+
.auth()
41+
.getProviderCredential(provider)
42+
.then((cred) => {
43+
firebase().auth().currentUser.linkWithCredential(cred);
44+
console.log('cred', cred);
45+
})
46+
.catch((e) => {
47+
console.log('Failed to link Github', e);
48+
});
49+
}
50+
51+
async linkYahoo() {
52+
if (!this.user) {
53+
return;
54+
}
55+
const provider = new OAuthProvider('yahoo.com');
56+
provider.addCustomParameter('prompt', 'login');
57+
provider.addCustomParameter('language', 'en');
58+
59+
firebase()
60+
.auth()
61+
.getProviderCredential(provider)
62+
.then((cred) => {
63+
firebase().auth().currentUser.linkWithCredential(cred);
64+
})
65+
.catch((e) => {
66+
console.log('Failed to link Yahoo', e);
67+
});
68+
}
69+
3170
async linkGoogle() {
3271
try {
3372
if (!this.user) {

apps/demo/src/plugin-demos/firebase-auth.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<Button text="Login User With Phone" tap="{{ loginWithPhone }}" class="btn btn-primary"/>
1717
<Button text="Link User Phone" tap="{{ linkPhone }}" class="btn btn-primary"/>
1818
<Button text="Link Google" tap="{{ linkGoogle }}" class="btn btn-primary"/>
19+
<Button text="Link user with Github" tap="{{ linkGithub }}" class="btn btn-primary"/>
20+
<Button text="Login user with Yahoo" tap="{{ linkYahoo }}" class="btn btn-primary"/>
1921
<Button text="Get Current User" tap="{{ getCurrentUser }}" class="btn btn-primary"/>
2022
<Button text="Logout User" tap="{{ logOutUser }}" class="btn btn-primary"/>
2123
<StackLayout>

tools/assets/App_Resources/iOS/GoogleService-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>REVERSED_CLIENT_ID</key>
88
<string>com.googleusercontent.apps.292142294722-23nmrq9mn8rhpqipjc1bt4qecga3qgsf</string>
99
<key>ANDROID_CLIENT_ID</key>
10-
<string>292142294722-ckf8oa3neiemb5ju5naesnkqqidbn92o.apps.googleusercontent.com</string>
10+
<string>292142294722-9s58kof5a3ng34vqhj51gs04qlr6jjgf.apps.googleusercontent.com</string>
1111
<key>API_KEY</key>
1212
<string>AIzaSyCYCaQR0vcgewpD1XhzsuSI9PHQugCtan4</string>
1313
<key>GCM_SENDER_ID</key>

0 commit comments

Comments
 (0)