Getting App meta data in android using lock

I get a Management Exception whenever I try to get the app metadata from the user profile, despite successful login.

private fun getProfile(accessToken: String) {
        authenticationAPIClient.userInfo(accessToken)
            .start(object : BaseCallback<UserProfile, AuthenticationException> {
                override fun onSuccess(userinfo: UserProfile) {
                    usersClient.getProfile(userinfo.id)
                        .start(object : BaseCallback<UserProfile, ManagementException> {
                            override fun onSuccess(profile: UserProfile) {
                                val orgID = profile.appMetadata["OrgID"] as String
                                val orgName = profile.appMetadata["OrgName"] as String
                                val orgType = profile.appMetadata["OrgType"] as String
                                App.prefs.orgID = orgID
                                App.prefs.orgName = orgName
                                App.prefs.orgType = orgType
                                Log.e("PostLogin",orgType)
                            }

                            override fun onFailure(error: ManagementException) {
                                // Show error
                                Log.e("PostLogin","management error")
                                error.printStackTrace()
                                //error.message
                                Log.e("PostLogin",error.message)

                            }
                        })
                }

                override fun onFailure(error: AuthenticationException) {
                    error.printStackTrace()
                    // Show error
                }
            })
    }

Error is as follows
com.auth0.android.management.ManagementException: An error occurred when trying to authenticate with the server.

–my code is in kotlin put if you point me to a java solution, that’s fine too. Thanks

Hi @koguno,

Can you look in the auth0 dashboard logs and see why the authentication if failing?