2017-07-27 43 views
0

私の会社のCRMアプリケーションを開発しています。私はauth0ライブラリを使用しており、ADFSへの認証を試みています。以下は、以下のコードです: Loginボタンを押すと、「パラメータに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> 
    ); 
    } 
} 

答えて

0

私はそれを引き起こしている可能性が見ることができる唯一のことは、次のとおりです。

var auth0 = new Auth0(credentials); 

が出て、この行をコメントしてみて、それでもエラーが出るかどうかを確認。

また、Auth0ダッシュボードからclientID全体を貼り付けたことを確認します。私はかなり確かにclientIDが約10文字ほど欠けていると確信しています。私のものは全部で32文字です。

ことが明示的にここに掲載されているものをフォロー動作しない場合:私は私の会社のプライバシーとセキュリティを維持するために、私のクライアントIDから文字を取り出した

https://auth0.com/docs/libraries/auth0js/v8

+0

。行をコメントアウトすると、アプリケーションは "auth0 not defined"エラーをスローします。 –

+0

申し訳ありません。私は資格のパラメータを削除することを意味しました –

+0

passwordRealmでログインするためのreact-native-auth0のドキュメントを反映するように私のコードを変更しました。私は今、不正なエラーメッセージを取得しています。私はADFSサーバーをまだセットアップしていないので、私は期待しています。 –

関連する問題