Expected behavior is to successfully authenticate with Google and save user info on backendless by passing a TOKEN ID.
I have one question. I’ve been trying to authenticate with Backendless using my Google account, from an android app. In my android app, I’m using One-Tap Sign in for Android, which allows me to authenticate all users with their Google account. After a successful authentication, I receive a JWT ID Token, which I’m including in: ‘Backendless.UserService.loginWithOAuth2()’ function in order to sign in to backendless and save user information.
However I’m constantly receiving an error message:
“error”: {
“code”: 401,
“message”: "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
“status”: “UNAUTHENTICATED”
}
Also I’ve created a project on my Google Cloud Platform, enabled Google + API, created OAuth credentials and added it’s secret key and client id to my backendless Google provider section as well. And copied back that redirect URL from backendless to my Google cloud platform project Oauth credentials.
Actual Behavior
I’m receiving error that authentication credential is missing.
“error”: {
“code”: 401,
“message”: "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
“status”: “UNAUTHENTICATED”
}
I thought that ID Token can also be exchanged with Backendless, because it’s a JWT which can be decoded to get the user information. One-Tap for Android is a new API, and I cannot receive anything other then ID Token from it. I mean I can extract user info on the client side, but I thought I could do that directly with backendless. Overview of One Tap sign-in on Android | One Tap for Android | Google Developers
@sergey.kuk Thank you for providing me with the code. However I’ve tried obtaining an Access Token out of Auth Code, but that function which I’ve copied from that code does not work and it’s returning null whenever I try to get an Access Token.
On the other side I’ve succeeded in obtaining the Auth Code.
I know that there’s another way of bypassing this with Web View in Android (I’ve read your documentation). However I think that’s a bad approach, mostly because of a user experience.
I encountered some issue, needed to uninstall the app…
The error was for running that function on a Main thread. Just fixed it.
Thank you for your help, really appreciate it!