Support Topics Documentation Slack YouTube Blog

BackendlessUserService method loginWithOauth2() can't deserialize instance of BackendlessUser

Hello,

I am trying to authenticate user with google provider, but I got error when I try to login with Oauth2 method. I pass guest BackendlessUser instance, but got exception JsonUnsupportedObjectError, for BackendlessUser instance, NoSuchMethodError (NoSuchMethodError: Class ‘DateTime’ has no instance method ‘toJson’.)

googleSignInAccount = await _googleSignIn.signIn(); //pass ok

GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication; //pass ok

BackendlessUser be = await Backendless.userService
    .loginWithOauth2(
  "googleplus",
  googleSignInAuthentication.accessToken,
  {"email": "email"},
  true,
  AuthServices.backendlessUser,
)

I am using:
backendless_sdk: ^6.2.0
Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (5 weeks ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5

Backendless Version (6.2.6, Online)
Client SDK Flutter
Application ID E06560C6-0B4C-05DF-FF4E-5A1AFAD4EB00

Hi @DB_Tower

We are looking into the issue.

Hi @Maksym_Khobotin2 is there any news regarding this issue? This is really urgent for us and we can not use functionality which is described as feature. I chose backendless because it has authentication with google but it’s not working.

Hi @DB_Tower

Sorry for the late response. I’ve created the internal ticket BKNDLSS-24318 with the high priority. We will fix your issue as soon as possible.

Best Regards,
Maksym

Hi @DB_Tower

The issue has been resolved. Please check new Flutter SDK release v.6.3.0.

Best Regards,
Maksym

Hi Maksym,

This is my code, I provide BackendlessUser which is loged in as a guest:
BackendlessUser be = await Backendless.userService.loginWithOauth2( "googleplus", googleSignInAuthentication.accessToken, {"email": "email"}, true, AuthServices.backendlessUser, );

But I got error below, BackedlessException:
code:3117
message:“Guest Backendless user not found by specified identity. For conversion existing guest user must be provided.”

I tried to debug your sdk and found that on post request, response is bad request 400.
You can check in my database there is user with that email, and email is identity column.
Am I doing something wrong? Or I didn’t set google provider correctly?

https://eu-api.backendless.com/3AF15BE8-3BDA-3F1B-FF01-BD7E58F6F800/463657C5-A012-4392-83EA-4BB0C9D9D9C7/users/social/googleplus/login

@DB_Tower

The body of your request looks wrong, when you pass the guest user, the “properties” property is redundant. If you remove it, the conversion and login will be successful.
https://monosnap.com/file/m8rglQtq1LoCGSQ7gXCNkhy8Lvj6tK
Please let me know if this helped you with your problem.

Regards,
Inna

Hi @Inna_Shkolnaya , yes you are right but you or @Maksym_Khobotin2 need to fix it in method Backendless.userService.loginWithOauth2(), because I debug that method and found that bad request.
When I call loginWithOauth2 I need to pass BackendlessUser object as guest user.

Please let me know.

Best regards,

Hello @DB_Tower

Thanks for the clarification. We apologise for the inconvenience.
The internal ticket BKNDLSS-24682 is created, we will let you know about solution.

Regards,
Inna