What is the purpose of this code in Firebase auth?
up vote
0
down vote
favorite
I looked at the FirebaseUI sign-in methods. on the first page of the explanation there is a "Sign in with a pre-built UI" as shown here: Easily add sign-in to your Android app with FirebaseUI. This page contains the following code:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
And then
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}
But, when I look at their example of the how to authenticate with phone via SMS, this code is no where to be seen, yet the verification works.
The phone authentication code can be seen in their snippet:
PhoneAuthActivity.java
So when do I need to use this code and when not? What is the purpose of this part?
android firebase firebase-authentication
add a comment |
up vote
0
down vote
favorite
I looked at the FirebaseUI sign-in methods. on the first page of the explanation there is a "Sign in with a pre-built UI" as shown here: Easily add sign-in to your Android app with FirebaseUI. This page contains the following code:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
And then
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}
But, when I look at their example of the how to authenticate with phone via SMS, this code is no where to be seen, yet the verification works.
The phone authentication code can be seen in their snippet:
PhoneAuthActivity.java
So when do I need to use this code and when not? What is the purpose of this part?
android firebase firebase-authentication
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I looked at the FirebaseUI sign-in methods. on the first page of the explanation there is a "Sign in with a pre-built UI" as shown here: Easily add sign-in to your Android app with FirebaseUI. This page contains the following code:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
And then
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}
But, when I look at their example of the how to authenticate with phone via SMS, this code is no where to be seen, yet the verification works.
The phone authentication code can be seen in their snippet:
PhoneAuthActivity.java
So when do I need to use this code and when not? What is the purpose of this part?
android firebase firebase-authentication
I looked at the FirebaseUI sign-in methods. on the first page of the explanation there is a "Sign in with a pre-built UI" as shown here: Easily add sign-in to your Android app with FirebaseUI. This page contains the following code:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
And then
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}
But, when I look at their example of the how to authenticate with phone via SMS, this code is no where to be seen, yet the verification works.
The phone authentication code can be seen in their snippet:
PhoneAuthActivity.java
So when do I need to use this code and when not? What is the purpose of this part?
android firebase firebase-authentication
android firebase firebase-authentication
asked Nov 21 at 22:28
TTnote
1799
1799
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
There are two main ways to implement Firebase Authentication:
- Use the so-called headless API and build your own API and flows on top of that.
- Use FirebaseUI, which is a UI library that (in this case) encapsulates the Firebase Authentication sign-in flow. It calls the Firebase Authentication API under the hood, as you can see in its open source implementation.
The first snippet you showed configures FirebaseUI, specifically saying what providers (Google, Facebook, Email+Password, Phone, Twitter) are enabled and then starting an activity to kick off the flow.
The second snippet uses the Firebase Authentication API directly to implement a part of the authentication flow.
If you're using FirebaseUI, follow the documentation for configuring phone number auth in its repo. As far as I can see there, this doesn't require the onActivityResult
you shared. Most likely that flow is already encapsulated in FirebaseUI itself.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
There are two main ways to implement Firebase Authentication:
- Use the so-called headless API and build your own API and flows on top of that.
- Use FirebaseUI, which is a UI library that (in this case) encapsulates the Firebase Authentication sign-in flow. It calls the Firebase Authentication API under the hood, as you can see in its open source implementation.
The first snippet you showed configures FirebaseUI, specifically saying what providers (Google, Facebook, Email+Password, Phone, Twitter) are enabled and then starting an activity to kick off the flow.
The second snippet uses the Firebase Authentication API directly to implement a part of the authentication flow.
If you're using FirebaseUI, follow the documentation for configuring phone number auth in its repo. As far as I can see there, this doesn't require the onActivityResult
you shared. Most likely that flow is already encapsulated in FirebaseUI itself.
add a comment |
up vote
2
down vote
accepted
There are two main ways to implement Firebase Authentication:
- Use the so-called headless API and build your own API and flows on top of that.
- Use FirebaseUI, which is a UI library that (in this case) encapsulates the Firebase Authentication sign-in flow. It calls the Firebase Authentication API under the hood, as you can see in its open source implementation.
The first snippet you showed configures FirebaseUI, specifically saying what providers (Google, Facebook, Email+Password, Phone, Twitter) are enabled and then starting an activity to kick off the flow.
The second snippet uses the Firebase Authentication API directly to implement a part of the authentication flow.
If you're using FirebaseUI, follow the documentation for configuring phone number auth in its repo. As far as I can see there, this doesn't require the onActivityResult
you shared. Most likely that flow is already encapsulated in FirebaseUI itself.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
There are two main ways to implement Firebase Authentication:
- Use the so-called headless API and build your own API and flows on top of that.
- Use FirebaseUI, which is a UI library that (in this case) encapsulates the Firebase Authentication sign-in flow. It calls the Firebase Authentication API under the hood, as you can see in its open source implementation.
The first snippet you showed configures FirebaseUI, specifically saying what providers (Google, Facebook, Email+Password, Phone, Twitter) are enabled and then starting an activity to kick off the flow.
The second snippet uses the Firebase Authentication API directly to implement a part of the authentication flow.
If you're using FirebaseUI, follow the documentation for configuring phone number auth in its repo. As far as I can see there, this doesn't require the onActivityResult
you shared. Most likely that flow is already encapsulated in FirebaseUI itself.
There are two main ways to implement Firebase Authentication:
- Use the so-called headless API and build your own API and flows on top of that.
- Use FirebaseUI, which is a UI library that (in this case) encapsulates the Firebase Authentication sign-in flow. It calls the Firebase Authentication API under the hood, as you can see in its open source implementation.
The first snippet you showed configures FirebaseUI, specifically saying what providers (Google, Facebook, Email+Password, Phone, Twitter) are enabled and then starting an activity to kick off the flow.
The second snippet uses the Firebase Authentication API directly to implement a part of the authentication flow.
If you're using FirebaseUI, follow the documentation for configuring phone number auth in its repo. As far as I can see there, this doesn't require the onActivityResult
you shared. Most likely that flow is already encapsulated in FirebaseUI itself.
answered Nov 22 at 0:59
Frank van Puffelen
221k25362387
221k25362387
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421321%2fwhat-is-the-purpose-of-this-code-in-firebase-auth%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown