我已经完成了django-rest-framework-jwt文档中的安装步骤,我无法运行curl $ curl -X POST -d“username = admin& password = abc123”http://localhost:8000/api-token-auth/ 。我无法取回令牌!相反,我收回了CSRF cookie错误:
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import io.reactivex.FlowableTransformer;
import io.reactivex.ObservableTransformer;
import io.reactivex.SingleTransformer;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
public class RxShowDialogUtil {
private ProgressDialog dialog;
private final Context context;
private final Consumer SUBSCRIBE_ACTION = new Consumer() {
@Override
public void accept(@NonNull Object o) throws Exception {
if (dialog != null && !dialog.isShowing()) {
dialog.show();
}
}
};
private final Action UN_SUBSCRIBE_ACTION = new Action() {
@Override
public void run() throws Exception {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
dialog = null;
}
};
private RxShowDialogUtil(Context context) {
this.context = context;
}
public static RxShowDialogUtil createInstance(Context context) {
return new RxShowDialogUtil(context);
}
public static RxShowDialogUtil createInstance(Fragment fragment) {
return new RxShowDialogUtil(fragment.getActivity());
}
public <T> SingleTransformer<T, T> applyDialogForSingle() {
createDialog(context);
return upstream -> upstream.doOnSubscribe(SUBSCRIBE_ACTION).doFinally(UN_SUBSCRIBE_ACTION);
}
public <T> ObservableTransformer<T, T> applyDialogForObservable() {
createDialog(context);
return upstream -> upstream.doOnSubscribe(SUBSCRIBE_ACTION).doFinally(UN_SUBSCRIBE_ACTION);
}
public <T>FlowableTransformer<T,T> applyDialogForFlowable(){
createDialog(context);
return upstream -> upstream.doOnSubscribe(SUBSCRIBE_ACTION).doFinally(UN_SUBSCRIBE_ACTION);
}
private Dialog createDialog(final Context context) {
if (dialog == null) {
dialog = DialogUtils.getInstance().getProgressDialog(context);
}
return dialog;
}
}