Skip to content

Firebase Auth add link domain to actionCodeSetting #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/com/google/firebase/auth/ActionCodeSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ private ActionCodeSettings(Builder builder) {
if (!Strings.isNullOrEmpty(builder.dynamicLinkDomain)) {
properties.put("dynamicLinkDomain", builder.dynamicLinkDomain);
}
if (!Strings.isNullOrEmpty(builder.linkDomain)) {
properties.put("linkDomain", builder.linkDomain);
}
if (!Strings.isNullOrEmpty(builder.iosBundleId)) {
properties.put("iOSBundleId", builder.iosBundleId);
}
Expand Down Expand Up @@ -83,7 +86,9 @@ public static final class Builder {

private String url;
private boolean handleCodeInApp;
// Deprecated, use linkDomain instead.
private String dynamicLinkDomain;
private String linkDomain;
private String iosBundleId;
private String androidPackageName;
private String androidMinimumVersion;
Expand Down Expand Up @@ -135,12 +140,27 @@ public Builder setHandleCodeInApp(boolean handleCodeInApp) {
*
* @param dynamicLinkDomain Firebase Dynamic Link domain string.
* @return This builder.
* @deprecated Use {@link #setLinkDomain(String)} instead.
*/
public Builder setDynamicLinkDomain(String dynamicLinkDomain) {
this.dynamicLinkDomain = dynamicLinkDomain;
return this;
}

/**
* Sets the link domain to use for the current link if it is to be opened using
* HandleCodeInApp, as multiple link domains can be configured per project. This
* setting provides the ability to explicitly choose one. If none is provided, the default
* Firebase Hosting domain will be used.
*
* @param linkDomain Link domain string.
* @return This builder.
*/
public Builder setLinkDomain(String linkDomain) {
this.linkDomain = linkDomain;
return this;
}

/**
* Sets the bundle ID of the iOS app where the link should be handled if the
* application is already installed on the device.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/google/firebase/auth/AuthErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public enum AuthErrorCode {
*/
INVALID_DYNAMIC_LINK_DOMAIN,

/**
* The provided hosting link domain is not configured or authorized for the current project.
*/
INVALID_HOSTING_LINK_DOMAIN,

/**
* The specified ID token is invalid.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ final class AuthErrorHandler extends AbstractHttpErrorHandler<FirebaseAuthExcept
"The provided dynamic link domain is not "
+ "configured or authorized for the current project",
AuthErrorCode.INVALID_DYNAMIC_LINK_DOMAIN))
.put(
"INVALID_HOSTING_LINK_DOMAIN",
new AuthError(
ErrorCode.INVALID_ARGUMENT,
"The provided hosting link domain is not "
+ "configured or authorized for the current project",
AuthErrorCode.INVALID_HOSTING_LINK_DOMAIN))
.put(
"PHONE_NUMBER_EXISTS",
new AuthError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testAllSettings() {
ActionCodeSettings settings = ActionCodeSettings.builder()
.setUrl("https://example.com")
.setHandleCodeInApp(true)
.setDynamicLinkDomain("myapp.page.link")
.setLinkDomain("myapp.custom.link")
.setIosBundleId("com.example.ios")
.setAndroidPackageName("com.example.android")
.setAndroidMinimumVersion("6.0")
Expand All @@ -76,7 +76,7 @@ public void testAllSettings() {
Map<String, Object> expected = ImmutableMap.<String, Object>builder()
.put("continueUrl", "https://example.com")
.put("canHandleCodeInApp", true)
.put("dynamicLinkDomain", "myapp.page.link")
.put("linkDomain", "myapp.custom.link")
.put("iOSBundleId", "com.example.ios")
.put("androidPackageName", "com.example.android")
.put("androidMinimumVersion", "6.0")
Expand Down