javascript - Firebase Passwordless Auth 在单击链接时显示未找到站点页面
问题描述
我对react-native
and非常firebase
陌生,我正在尝试设置Passwordless Auth
.
我已经写的代码:
import React, {Component} from 'react';
import {View, TextInput, Button} from 'react-native';
import auth from '@react-native-firebase/auth';
import AsyncStorage from '@react-native-community/async-storage';
class App extends Component {
constructor(props) {
super(props);
this.state = {
email: '',
emailSent: false,
};
}
setEmail = async email => {
try {
await AsyncStorage.setItem('emailLink', `${email}`);
} catch (e) {
// save error
}
console.log('Email is set');
};
getEmail = async () => {
try {
var value = await AsyncStorage.getItem('emailLink');
} catch (e) {
// read error
}
console.log('Got email: ', value);
};
sendEmailLink() {
var actionCodeSettings = {
// The URL to redirect to for sign-in completion. This is also the deep
// link for mobile redirects. The domain (www.example.com) for this URL
// must be whitelisted in the Firebase Console.
url: 'https://passless.page.link/85EH',
iOS: {
bundleId: 'org.reactjs.native.example.passless',
},
android: {
packageName: 'com.passless_auth',
installApp: true,
minimumVersion: '12',
},
// This must be true.
handleCodeInApp: true,
};
auth()
.sendSignInLinkToEmail(`${this.state.email}`, actionCodeSettings)
.then(() => console.log('email is sent'))
.then(() => this.setEmail(`${this.state.email}`))
.catch(err => console.log('error sending email', err));
}
render() {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<TextInput
placeholder="email"
onChangeText={email => this.setState({email: email})}
/>
<Button title="SignUp/LogIn" onPress={() => this.sendEmailLink()} />
</View>
);
}
}
export default App;
我已成功收到电子邮件,但链接无效。
电子邮件中的链接会在浏览器而不是应用程序中打开。我该如何解决这个问题?
我想我已经正确设置了控制台中的链接,但我不确定我的代码。
我如何进一步进步?帮助将不胜感激。
PS我正在使用react-native-firebase v6
解决方案
当您将重定向 URL 从默认 URL 更改为未在 GCP 上的项目中注册的其他重定向 URL 时,就会发生这种情况。
确保在 GCP oAuth 同意的 Firebase 项目凭据部分中将重定向 URL 列入白名单。
https://console.cloud.google.com/apis/credentials/consent
确保已将您的重定向 URL 列入白名单。
我希望这有帮助。如果您遇到问题,请告诉我。
推荐阅读
- python - 关于 values('created_at__day') 和 values('created_at__week')
- pointers - 弧
> 成弧 > 使用不安全的指针 - graph - 如何返回与另一个节点同名但具有特定标签的节点?Neo4J
- java - 如何通过 REST API Mule 4 上传 zip 文件?
- sql - ORACLE SQL中如何对奇偶行号进行排序?
- typescript - NestJS测试错误:在E2E测试mocha中找不到编译的js文件
- java - 带有访问密钥和密钥的谷歌云存储连接(没有客户端密钥 json)
- javascript - 如何在没有 babel 的情况下“导入”对象(使用 CDN)
- php - 优化太慢的php函数
- r - 如何在 R 中对数据框进行分组和转置