Skip to content

Commit 9716f4d

Browse files
committed
Fixes based on comments
1 parent 178406b commit 9716f4d

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

auth-next/oidc.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function oidcSignInPopup(provider) {
1717
signInWithPopup(auth, provider)
1818
.then((result) => {
1919
// User is signed in.
20+
credential = OAuthProvider.credentialFromResult(result);
21+
// This gives you an access token for the OIDC provider. You can use it to directly interact with that provider
2022
}).catch((error) => {
2123
// Handle Errors here.
2224
const errorCode = error.code;
@@ -25,6 +27,7 @@ function oidcSignInPopup(provider) {
2527
const email = error.email;
2628
// The AuthCredential type that was used.
2729
const credential = OAuthProvider.credentialFromError(error);
30+
// Handle / display error.
2831
// ...
2932
});
3033
// [END auth_oidc_signin_popup]
@@ -46,8 +49,9 @@ function oidcSignInRedirectResult(provider) {
4649
const auth = getAuth();
4750
getRedirectResult(auth)
4851
.then((result) => {
52+
// User is signed in.
4953
credential = OAuthProvider.credentialFromResult(result);
50-
// ...
54+
// This gives you an access token for the OIDC provider. You can use it to directly interact with that provider
5155
})
5256
.catch((error) => {
5357
// Handle Errors here.
@@ -57,8 +61,7 @@ function oidcSignInRedirectResult(provider) {
5761
const email = error.email;
5862
// The AuthCredential type that was used.
5963
const credential = OAuthProvider.credentialFromError(error);
60-
console.log(error);
61-
console.log(credential);
64+
// Handle / display error.
6265
// ...
6366
});
6467
// [END auth_oidc_signin_redirect_result]
@@ -74,8 +77,9 @@ function oidcDirectSignIn(provider, oidcIdToken) {
7477
})
7578
signInWithCredential(auth, credential)
7679
.then((result) => {
80+
// User is signed in.
7781
credential = OAuthProvider.credentialFromResult(result);
78-
// ...
82+
// This gives you a new access token for the OIDC provider. You can use it to directly interact with that provider.
7983
})
8084
.catch((error) => {
8185
// Handle Errors here.
@@ -85,8 +89,7 @@ function oidcDirectSignIn(provider, oidcIdToken) {
8589
const email = error.email;
8690
// The AuthCredential type that was used.
8791
const credential = OAuthProvider.credentialFromError(error);
88-
console.log(error);
89-
console.log(credential);
92+
// Handle / display error.
9093
// ...
9194
});
9295
// [END auth_oidc_direct_sign_in]

auth-next/saml.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function samlSignInPopup(provider) {
1717
signInWithPopup(auth, provider)
1818
.then((result) => {
1919
// User is signed in.
20+
// Provider data available from the result.user.getIdToken()
21+
// or from result.user.providerData
2022
}).catch((error) => {
2123
// Handle Errors here.
2224
const errorCode = error.code;
@@ -25,6 +27,7 @@ function samlSignInPopup(provider) {
2527
const email = error.email;
2628
// The AuthCredential type that was used.
2729
const credential = SAMLAuthProvider.credentialFromError(error);
30+
// Handle / display error.
2831
// ...
2932
});
3033
// [END auth_saml_signin_popup]
@@ -46,8 +49,9 @@ function samlSignInRedirectResult(provider) {
4649
const auth = getAuth();
4750
getRedirectResult(auth)
4851
.then((result) => {
49-
credential = SAMLAuthProvider.credentialFromResult(result);
50-
// ...
52+
// User is signed in.
53+
// Provider data available from the result.user.getIdToken()
54+
// or from result.user.providerData
5155
})
5256
.catch((error) => {
5357
// Handle Errors here.
@@ -57,8 +61,7 @@ function samlSignInRedirectResult(provider) {
5761
const email = error.email;
5862
// The AuthCredential type that was used.
5963
const credential = SAMLAuthProvider.credentialFromError(error);
60-
console.log(error);
61-
console.log(credential);
64+
// Handle / display error.
6265
// ...
6366
});
6467
// [END auth_saml_signin_redirect_result]

auth/oidc.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function oidcSignInPopup(provider) {
1111
// [START auth_oidc_signin_popup]
1212
firebase.auth().signInWithPopup(provider)
1313
.then((result) => {
14+
// User is signed in.
1415
// result.credential is a firebase.auth.OAuthCredential object.
1516
// result.credential.providerId is equal to 'oidc.myProvider'.
1617
// result.credential.idToken is the OIDC provider's ID token.
@@ -34,12 +35,14 @@ function oidcSignInRedirectResult(provider) {
3435
// On return.
3536
firebase.auth().getRedirectResult()
3637
.then((result) => {
38+
// User is signed in.
3739
// result.credential is a firebase.auth.OAuthCredential object.
3840
// result.credential.providerId is equal to 'oidc.myProvider'.
3941
// result.credential.idToken is the OIDC provider's ID token.
4042
})
4143
.catch((error) => {
42-
// Handle error.
44+
// Handle / display error.
45+
// ...
4346
});
4447
// [END auth_oidc_signin_redirect_result]
4548
}
@@ -50,10 +53,12 @@ function oidcDirectSignIn(provider, oidcIdToken) {
5053

5154
firebase.auth().signInWithCredential(credential)
5255
.then((result) => {
53-
// user now has a odic.myProvider UserInfo in providerData.
56+
// User is signed in.
57+
// User now has a odic.myProvider UserInfo in providerData.
5458
})
5559
.catch((error) => {
56-
// Handle error.
60+
// Handle / display error.
61+
// ...
5762
});
5863
// [END auth_oidc_direct_sign_in]
5964
}

auth/saml.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function samlSignInPopup(provider) {
1919
// idTokenResult.claims.firebase.sign_in_attributes.
2020
})
2121
.catch((error) => {
22-
// Handle error.
22+
// Handle / display error.
23+
// ...
2324
});
2425
// [END auth_saml_signin_popup]
2526
}
@@ -41,8 +42,9 @@ function samlSignInRedirectResult(provider) {
4142
// This is also available from result.user.getIdTokenResult()
4243
// idTokenResult.claims.firebase.sign_in_attributes.
4344
}).catch((error) => {
44-
// Handle error.
45-
});
46-
// [END auth_saml_signin_redirect_result]
45+
// Handle / display error.
46+
// ...
47+
});
48+
// [END auth_saml_signin_redirect_result]
4749
}
4850

0 commit comments

Comments
 (0)