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

Hello @Inna_Shkolnaya,

I think this takes a lot of time. This conversation started Feb 25, more then 2 months.
I pay you 300$ for service that you advertise on your site, which simply doesn’t work! Look at your app, you mentioned 15 login providers, how many of them doesn’t work? Should I test them all? Will you give me salary as a tester?

Least what you can do is to refund me some funds. This is not bad experience, this is catastrophic user experience! My application depends on authenticated users.

I can understand everything, but you can not advertise something that you don’t provide to clients. Please fix it, or simply remove Google as authentication provider. You are misleading clients.

Hello @DB_Tower

We are really sorry that you have such a bad experience with this feature and we totally understand your feeling and how it is important for your business!
The issue is reproduced only with Flutter SDK and that ticket BKNDLSS-24682 has the highest priority. It’g going to be fixed as soon as it only possible.

Regards, Vlad

Hello @DB_Tower

We have fixed the issue and published a new release version 6.3.2. Could you please update the dependency and verify everything works fine for you?

backendless_sdk: ^6.3.2

We sincerely apologize for this situation. And we made sure it will not happen again.

Best Regards,
Maksym

Hello @Maksym_Khobotin2 ,

Authentication works now, but I have another issue.
I have configured security roles to have all rights over data, and when I login user as a guest it gets all necessary rights, but when I transfer that guest user to authenticated user, user lose all rights over all tables. Should I configure something more or there is a bug?

Hello @DB_Tower

If you want this transformed user (dbtower64@gmail.com) to also have retrieve permission, then you need to add permission for all his roles, in this case there are not enough rights for the SocialUser.

Hi @Vladimir_Yalovy, could you please check if login method keep authenticated user logged in? Because when I convert guest user to authenticated user, I pass ‘true’ as stay logged in parameter, but when I restart my flutter application, I got message ‘user with that token doesn’t exists, please reloggin user’. So I need to call login method again.

Backendless.userService.loginWithOauth2(
“googleplus”,
googleSignInAuthentication.accessToken,
{“email”: “email”},
true,
);