Facebook Login with Auth0

Hello guys,

I’m trying to login/ sign up with Facebook via the Authentication API on Android. However, every time I hit the webview I’m redirected back to my application but I don’t receive credentials. Auth0’s dashboard for my account also shows I’m logged in but I’m not getting credentials. Why might this be?

We currently have this set up.

webAuthBuilder.withConnection(connection)
.withAudience(BuildConfig.API_HOST)
.withScheme(SCHEME)
.withScope(SOCIAL_LOGIN_SCOPE)

Hello @rondale.williams, welcome to the Auth0 Community!

Are you experiencing any failure with any other social connectors other than facebook? When the failure occurs, do you see anything in the Auth0 Dashboard Logs? Thanks!

Hi James,

I don’t see any failures with Facebook or our Spotify connection. I’m able to login or signup as I see in the Auth0 dashboard but I don’t have any credentials returned here in the AuthCallback:

 .start(activity, object : AuthCallback {
                        override fun onSuccess(credentials: Credentials) {
                            emitter.onSuccess(credentials)
                            storeCredentials(credentials)
                        }

                        override fun onFailure(dialog: Dialog) {
                        }

                        override fun onFailure(error: AuthenticationException?) {
                            error?.let {
                                Timber.e(it)
                                emitter.onError(error)
                            }
                        }
                    })
        }

Here is our class:

private const val EMAIL_PASSWORD_CONNECTION = redacted
private const val SOCIAL_LOGIN_SCOPE = "openid email profile"
private const val SCHEME = redacted

class AuthenticationManager(
        private val authentication: AuthenticationAPIClient,
        private val webAuthBuilder: WebAuthProvider.Builder,
        private val credentialsManager: CredentialsManager) : Authentication.Manager {

    override fun login(email: String, password: String): Single<Credentials?> {
        return Single.create { emitter ->
            authentication
                    .login(email, password, EMAIL_PASSWORD_CONNECTION)
                    .setAudience(BuildConfig.API_HOST)
                    .start(object : BaseCallback<Credentials, AuthenticationException> {

                        override fun onSuccess(credentials: Credentials?) {
                            if (credentials != null) {
                                storeCredentials(credentials)
                                emitter.onSuccess(credentials)
                            } else {
                                emitter.onError(
                                        HsAuthenticationException(
                                                HsAuthenticationException
                                                        .CREDENTIALS))
                            }
                        }

                        override fun onFailure(error: AuthenticationException?) {
                            error?.let {
                                Timber.e(it)
                                emitter.onError(error)
                            }
                        }
                    })
        }
    }

    override fun socialLogin(activity: Activity, connection: String): Single<Credentials> {
        return Single.create { emitter ->
            webAuthBuilder.withConnection(connection)
                    .withAudience(BuildConfig.API_HOST)
                    .withScheme(SCHEME)
                    .withScope(SOCIAL_LOGIN_SCOPE)
                    .start(activity, object : AuthCallback {
                        override fun onSuccess(credentials: Credentials) {
                            emitter.onSuccess(credentials)
                            storeCredentials(credentials)
                        }

                        override fun onFailure(dialog: Dialog) {
                        }

                        override fun onFailure(error: AuthenticationException?) {
                            error?.let {
                                Timber.e(it)
                                emitter.onError(error)
                            }
                        }
                    })
        }
    }

Following up @rondale.williams, nothing looks obvious with the code you posted. In fact with Universal login successfully taking place, the redirect from UL may be the source of the issue but it’s hard to be certain. Is there some way you can test with the Android studio to confirm the state is being redirected to the right place? Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.