我尝试使用Auth0 for android 我想我已经完成了所有工作,但仍然会出现这个错误:
E/LockActivity: Failed to authenticate the user: An error occurred when trying to authenticate with the server.
com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server.
...
我的班级用于运行身份验证:
package com.my.awesome.app.modules;
public class AuthZeroModule extends ReactContextBaseJavaModule {
private ReactApplicationContext mReactContext;
private Lock mLock;
public AuthZeroModule(ReactApplicationContext reactContext) {
super(reactContext);
mReactContext = reactContext;
}
@Override
public String getName() {
return "AuthZero";
}
@ReactMethod
public void authenticate() {
Log.e("LSA", "=============authenticate");
Log.e("LSA", "=============CLIENT: " + AUTH0_CLIENT + " DOMAIN: " + AUTH0_DOMAIN);
Auth0 account = new Auth0("ZXXXXXXXXXXXXXXXXI", "myawesomeauth.eu.auth0.com");
account.setOIDCConformant(true);
mLock = Lock.newBuilder(account, callback)
.withScheme("https")
.withAudience("myapp.middleware.api")
// .withAudience("https://myawesomeauth.eu.auth0.com/authorize")
.allowLogIn(true)
.aut
.build(mReactContext);
mReactContext.startActivity(mLock.newIntent(mReactContext));
}
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Credentials credentials) {
Log.e("LSA", "OK -->" + credentials.getAccessToken());
}
@Override
public void onCanceled() {
Log.e("LSA", "OK --> User pressed back.");
}
@Override
public void onError(LockException error) {
Log.e("LSA", "OK -->" + error.getMessage());
}
};
}
并且在Auth0管理员内部我已准备好回调字段'允许的回拨网址':
https://myawesomeauth.eu.auth0.com/androidcom.my.awesome.app/callback,
我已开启Use Auth0 instead of the IdP to do Single Sign On
我为IOS使用相同的客户端,并且每个工作正常好芽安卓有此身份验证错误。
我将感激你的每一个建议......谢谢
答案 0 :(得分:0)
刚刚遇到了类似的问题。错误不是很详细,令人沮丧。
添加
account.setLoggingEnabled(true)
在下面的内容中提供了更详细的错误。
Auth0 account = new Auth0("ZXXXXXXXXXXXXXXXXI", "myawesomeauth.eu.auth0.com");
account.setOIDCConformant(true);
仅在预生产中使用它,因为当一切正常工作时它会记录秘密。