OAuthLogin2 for Kotlin

When using loginWithOAuth2, I am getting the error as shown below.

This error is being cause by the parameter stayLoggedIn. Since the Libraries are for Java, is there a way to do this in Kotlin? So far, facing no issues other than this.

Thanks,

Michael Iverson

Hi @Michael_Iverson ,

Basing on your screenshot I can asume that you have syntax error because you haven’t passed “provider code” and “stay logged in” params to the loginWithOAuth2 method call (they are required according to the method signature). Provider code should be passed before the token param and “stay logged in” should be hassed as the last param to the method call.
Could you please try to change your code according to my advice and write me back about results?

Regards, Andriy

Hi Andriy,

I tried a couple of ways:

and

@Michael_Iverson ,

In both cases your code doesn’t look correct (that is why IDE highlights it with red color ). stayLoggedIn: Boolean seems to be a method param definition in Kotlin, not the value itself. Value for that param should be true or false and should be passed as the last param. Also you haven’t passed value for “provider code” param (which is the first param).

I suggest you to check Kotlin syntax for better understanding of your current problem.

Regards, Andriy

Hi Andiry,

Unfortunately, it seems that the AsyncCallback and Boolean has a weird setup for Kotlin. See the Java code from the Backendless API:

@Michael_Iverson ,

I do not see any problems with Java SDK in Kotlin code. Here is an example of the correct method call:

Backendless.UserService.loginWithOAuth2(
            "facebook",
            "token",
            HashMap(),
            object : AsyncCallback<BackendlessUser?> {
                override fun handleResponse(response: BackendlessUser?) {
                    // some additional logic for logged in user
                }

                override fun handleFault(fault: BackendlessFault) {
                    // error handling logic
                }
            },
            true
        )

As you can see I passed in correct order all method params and in my case there were no errors from IDE.
As I wrote you before, you haven’t passed “provider code” to the method and used invalid Kotlin syntax when you tried to pass “stay logged in” param.

Regards, Andriy

Hi Andiry,

Thank you! I missed that. I have made the correction. The solution is resolved.

Cheers,

Michael Iverson