Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return WooJWTResponse authResponse null #42

Open
ngominhtrungit opened this issue Dec 6, 2020 · 6 comments
Open

return WooJWTResponse authResponse null #42

ngominhtrungit opened this issue Dec 6, 2020 · 6 comments

Comments

@ngominhtrungit
Copy link

inside authenticationJWT, response.body (body returns token, nicename ...)
but when assigning WooJWTResponse authResponse =
WooJWTResponse.fromJson (json.decode (response.body));

then authResponse == null.

Has anyone encountered this error, please help me

@ngominhtrungit
Copy link
Author

Since I currently use the authenticationJWT of the failed package, I manually customized the model and response, and it works successfully.

@kaplumbagalar
Copy link

Hello, I have the same issue. Can you share your customization please?

@ngominhtrungit
Copy link
Author

Of couse, wait me, because now I have to go out. I will sent you

@ngominhtrungit
Copy link
Author

///custom login
/// endpoint: https://domain.com/
/// https://domain.com/wp-json/jwt-auth/v1/token
///
loginCustomerCustom(String username, String password) async {
LoginModel customer;
try {
var response = await Dio().post(wooCommerceAPI.baseUrl + URL_JWT_TOKEN,
data: {
"username": username,
"password": password,
},
options: new Options(headers: {
HttpHeaders.contentTypeHeader: "appication/X-WWW-form-urlencoded",
}));
print('out: ${wooCommerceAPI.baseUrl + URL_JWT_TOKEN}');
if (response.statusCode == 200) {
print('loginCustomerCustom out: ${response.data['statusCode']}');
if (response.data['statusCode'] >= 300) {
//print('lỗi');
throw ("Sai Tên đăng nhập, mail hoặc mất khẩu!");
}

    //Data authResponse =
    //Data.fromJson(response.data);

    customer = LoginModel.fromJson(response.data);
  }
} on DioError catch (e) {
  print('loginCustomerCustom lỗi:${e.message}');
}
return customer;

}

@kaplumbagalar
Copy link

Thank you. Now it works.

@ngominhtrungit
Copy link
Author

So good. See you late

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants