0
我正在爲我的公司開發CRM應用程序。我正在使用auth0庫並嘗試向ADFS進行身份驗證。這裏是下面的代碼: 當我按下登錄按鈕時,我收到一個錯誤「在參數中缺少clientId」。不知道我在這裏錯過了什麼。任何幫助表示讚賞!創建新的Auth0並將其保存到auth0時,我輸入了憑據。參數中缺少clientId錯誤
export default class Login extends Component {
constructor(props) {
super(props);
}
state = {
email: "",
password: "",
error: "",
loading: false,
loggedIn: null
};
onButtonPress() {
const { email, password } = this.state;
this.setState({
email: { email },
password: { password },
error: "",
loading: true,
loggedIn: false
});
var auth0 = new Auth0(credentials);
var webAuth = new auth0.WebAuth({
domain: "crm.auth0.com",
clientID: "6ZiWpn7DbTHVO2ktagE1h4"
});
// auth0
// .webAuth
// .authorize({scope: 'openid email', audience: 'https://issicrm.auth0.com/userinfo'})
// .then(credentials => console.log(credentials))
// .catch(error => console.log(error));
webAuth.client.login(
{
clientID: "6ZiWpn7DbTHVzjtO071y1h4",
realm: "crm",
username: { email },
password: { password },
scope: "openid profile",
audience: "https://crm.auth0.com/userinfo"
},
function(err, authResult) {
if (authResult) {
// Save the tokens from the authResult
// in local storage or a cookie
alert("logged in!!");
console.log(authResult);
localStorage.setItem("access_token", authResult.accessToken);
localStorage.setItem("id_token", authResult.idToken);
this.onAuthSuccess();
} else if (err) {
console.log(err);
this.onAuthFailed();
}
}
);
}
onAuthSuccess() {
this.setState({
email: "",
password: "",
error: "",
loading: false,
loggedIn: true
});
this.props.succesHandler();
navigate("SalesOrderList");
}
onAuthFailed() {
this.setState({
error: "Authentication Failed",
loading: false,
loggedIn: false
});
this.props.failureHandler();
}
render() {
const { navigate } = this.props.navigation;
const {
form,
fieldStyles,
loginButtonArea,
errorMessage,
welcome,
container
} = styles;
return (
<View style={styles.container}>
<Text style={styles.labelText}>Login to ISSI CRM</Text>
<MKTextField
text={this.state.email}
onTextChange={email => this.setState({ email })}
textInputStyle={fieldStyles}
placeholder={"Email..."}
tintColor={MKColor.Teal}
/>
<MKTextField
text={this.state.password}
onTextChange={password => this.setState({ password })}
textInputStyle={fieldStyles}
placeholder={"Password..."}
tintColor={MKColor.Teal}
password={true}
/>
<Text style={errorMessage}>
{this.state.error}
</Text>
<View style={loginButtonArea}>
<LoginButton onPress={this.onButtonPress.bind(this)} />
</View>
</View>
);
}
}
我從我的客戶端ID拿出字符維護我公司的隱私和安全。如果我註釋掉該行,應用程序將拋出「auth0 not defined」錯誤。 –
對不起。我的意思是刪除憑證參數 –
我更改了我的代碼,以便它反映瞭如何使用passwordRealm登錄的react-native-auth0文檔。我現在收到未經授權的錯誤消息。我希望它是因爲我們還沒有設置我們的ADFS服務器。 –