Auth0:致命异常:OkHttp Dispatcher

时间:2017-07-23 15:38:37

标签: android auth0

当我尝试在此链接上关注Auth0的登录演示教程时,我收到致命错误异常:link,一切都在教程中实现,这里是stacktrace:

FATAL EXCEPTION: OkHttp Dispatcher
                                             Process: ke.co.noel.hao, PID: 7872
                                             com.google.gson.JsonParseException: Missing required attribute callback
                                                 at com.auth0.android.lock.internal.configuration.GsonDeserializer.requiredValue(GsonDeserializer.java:40)
                                                 at com.auth0.android.lock.internal.configuration.ApplicationDeserializer.deserialize(ApplicationDeserializer.java:51)
                                                 at com.auth0.android.lock.internal.configuration.ApplicationDeserializer.deserialize(ApplicationDeserializer.java:40)
                                                 at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
                                                 at com.google.gson.Gson.fromJson(Gson.java:887)
                                                 at com.google.gson.Gson.fromJson(Gson.java:852)
                                                 at com.google.gson.Gson.fromJson(Gson.java:801)
                                                 at com.auth0.android.lock.internal.configuration.ApplicationFetcher.parseJSONP(ApplicationFetcher.java:132)
                                                 at com.auth0.android.lock.internal.configuration.ApplicationFetcher.access$100(ApplicationFetcher.java:51)
                                                 at com.auth0.android.lock.internal.configuration.ApplicationFetcher$1.onResponse(ApplicationFetcher.java:99)
                                                 at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
                                                 at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
                                                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                 at java.lang.Thread.run(Thread.java:761)

这是LoginActivity:

public class LoginActivity extends Activity {

private Lock mLock;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Auth0 auth0 = new Auth0(this);
    auth0.setOIDCConformant(true);
    mLock = Lock.newBuilder(auth0, mCallback)
            .withScheme("demo")
            .withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
            //Add parameters to the builder
            .build(this);
    startActivity(mLock.newIntent(this));
}

@Override
protected void onDestroy() {
    super.onDestroy();
    // Your own Activity code
    mLock.onDestroy(this);
    mLock = null;
}

private final LockCallback mCallback = new AuthenticationCallback() {
    @Override
    public void onAuthentication(Credentials credentials) {
        Toast.makeText(getApplicationContext(), "Log In - Success", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(getApplicationContext(), MainActivity.class));
        finish();
    }

    @Override
    public void onCanceled() {
        Toast.makeText(getApplicationContext(), "Log In - Cancelled", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onError(LockException error) {
        Toast.makeText(getApplicationContext(), "Log In - Error Occurred", Toast.LENGTH_SHORT).show();
    }
};

1 个答案:

答案 0 :(得分:0)

回调链接无效。如果登录成功,此链接将设置为目标 在AuthenticationCallback属性callback中?如果是,请设置此项!