Giter VIP home page Giter VIP logo

auth0.android's Introduction

Note As part of our ongoing commitment to best security practices, we have rotated the signing keys used to sign previous releases of this SDK. As a result, new patch builds have been released using the new signing key. Please upgrade at your earliest convenience.

While this change won't affect most developers, if you have implemented a dependency signature validation step in your build process, you may notice a warning that past releases can't be verified. This is expected, and a result of the key rotation process. Updating to the latest version will resolve this for you.

Auth0.Android

Maven Central Coverage Status CircleCI License javadoc

📚 Documentation • 🚀 Getting Started • 💬 Feedback

Documentation

Getting Started

Requirements

Android API version 31 or later and Java 8+.

⚠️ Applications targeting Android SDK version 30 and below should use version 2.9.0.

Here’s what you need in build.gradle to target Java 8 byte code for Android and Kotlin plugins respectively.

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
}

Installation

To install Auth0.Android with Gradle, simply add the following line to your build.gradle file:

dependencies {
    implementation 'com.auth0.android:auth0:2.11.0'
}

Permissions

Open your app's AndroidManifest.xml file and add the following permission.

<uses-permission android:name="android.permission.INTERNET" />

Configure the SDK

First, create an instance of Auth0 with your Application information

val account = Auth0("{YOUR_CLIENT_ID}", "{YOUR_DOMAIN}")
Using Java
Auth0 account = new Auth0("{YOUR_CLIENT_ID}", "{YOUR_DOMAIN}");
Configure using Android Context

Alternatively, you can save your Application information in the strings.xml file using the following names:

<resources>
    <string name="com_auth0_client_id">YOUR_CLIENT_ID</string>
    <string name="com_auth0_domain">YOUR_DOMAIN</string>
</resources>

You can then create a new Auth0 instance by passing an Android Context:

val account = Auth0(context)

Authentication with Universal Login

First go to the Auth0 Dashboard and go to your application's settings. Make sure you have in Allowed Callback URLs a URL with the following format:

https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback

⚠️ Make sure that the application type of the Auth0 application is Native.

Replace {YOUR_APP_PACKAGE_NAME} with your actual application's package name, available in your app/build.gradle file as the applicationId value.

Next, define the Manifest Placeholders for the Auth0 Domain and Scheme which are going to be used internally by the library to register an intent-filter. Go to your application's build.gradle file and add the manifestPlaceholders line as shown below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.auth0.samples"
        minSdkVersion 21
        targetSdkVersion 30
        //...

        //---> Add the next line
        manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "https"]
        //<---
    }
    //...
}

It's a good practice to define reusable resources like @string/com_auth0_domain, but you can also hard-code the value.

The scheme value can be either https or a custom one. Read this section to learn more.

Declare the callback instance that will receive the authentication result and authenticate by showing the Auth0 Universal Login:

val callback = object : Callback<Credentials, AuthenticationException> {
    override fun onFailure(exception: AuthenticationException) {
        // Failure! Check the exception for details
    }

    override fun onSuccess(credentials: Credentials) {
        // Success! Access token and ID token are presents
    }
}

WebAuthProvider.login(account)
    .start(this, callback)
Using coroutines
try {
    val credentials = WebAuthProvider.login(account)
        .await(requireContext())
    println(credentials)    
} catch(e: AuthenticationException) {
    e.printStacktrace()
}
Using Java
Callback<Credentials, AuthenticationException> callback = new Callback<Credentials, AuthenticationException>() {
    @Override
    public void onFailure(@NonNull AuthenticationException exception) {
        //failed with an exception
    }

    @Override
    public void onSuccess(@Nullable Credentials credentials) {
        //succeeded!
    }
};

WebAuthProvider.login(account)
    .start(this, callback);

The callback will get invoked when the user returns to your application. There are a few scenarios where this may fail:

  • When the device cannot open the URL because it doesn't have any compatible browser application installed. You can check this scenario with error.isBrowserAppNotAvailable.
  • When the user manually closed the browser (e.g. pressing the back key). You can check this scenario with error.isAuthenticationCanceled.
  • When there was a server error. Check the received exception for details.

If the redirect URL is not found in the Allowed Callback URLs of your Auth0 Application, the server will not make the redirection and the browser will remain open.

A note about App Deep Linking:

If you followed the configuration steps documented here, you may have noticed the default scheme used for the Callback URI is https. This works best for Android API 23 or newer if you're using Android App Links, but in previous Android versions this may show the intent chooser dialog prompting the user to choose either your application or the browser. You can change this behaviour by using a custom unique scheme so that the OS opens directly the link with your app.

  1. Update the auth0Scheme Manifest Placeholder on the app/build.gradle file or update the intent-filter declaration in the AndroidManifest.xml to use the new scheme.
  2. Update the Allowed Callback URLs in your Auth0 Dashboard application's settings.
  3. Call withScheme() in the WebAuthProvider builder passing the custom scheme you want to use.
WebAuthProvider.login(account)
    .withScheme("myapp")
    .start(this, callback)

Note that the schemes can only have lowercase letters.

Clearing the session

To log the user out and clear the SSO cookies that the Auth0 Server keeps attached to your browser app, you need to call the logout endpoint. This can be done in a similar fashion to how you authenticated before: using the WebAuthProvider class.

Make sure to revisit this section to configure the Manifest Placeholders if you still cannot authenticate successfully. The values set there are used to generate the URL that the server will redirect the user back to after a successful log out.

In order for this redirection to happen, you must copy the Allowed Callback URLs value you added for authentication into the Allowed Logout URLs field in your application settings. Both fields should have an URL with the following format:

https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback

Remember to replace {YOUR_APP_PACKAGE_NAME} with your actual application's package name, available in your app/build.gradle file as the applicationId value.

Initialize the provider, this time calling the static method logout.

//Declare the callback that will receive the result
val logoutCallback = object: Callback<Void?, AuthenticationException> {
    override fun onFailure(exception: AuthenticationException) {
        // Failure! Check the exception for details
    }

    override fun onSuccess(result: Void?) {
        // Success! The browser session was cleared
    }
}

//Configure and launch the log out
WebAuthProvider.logout(account)
        .start(this, logoutCallback)
Using coroutines
try {
    WebAuthProvider.logout(account)
        .await(requireContext())
    println("Logged out")
} catch(e: AuthenticationException) {
    e.printStacktrace()
}
Using Java
//Declare the callback that will receive the result
Callback<Void, AuthenticationException> logoutCallback = new Callback<Void, AuthenticationException>() {
    @Override
    public void onFailure(@NonNull Auth0Exception exception) {
        //failed with an exception
    }

    @Override
    public void onSuccess(@Nullable Void payload) {
        //succeeded!
    }
};

//Configure and launch the log out
WebAuthProvider.logout(account)
    .start(MainActivity.this, logoutCallback);

The callback will get invoked when the user returns to your application. There are a few scenarios where this may fail:

  • When the device cannot open the URL because it doesn't have any compatible browser application installed. You can check this scenario with error.isBrowserAppNotAvailable.
  • When the user manually closed the browser (e.g. pressing the back key). You can check this scenario with error.isAuthenticationCanceled.

If the returnTo URL is not found in the Allowed Logout URLs of your Auth0 Application, the server will not make the redirection and the browser will remain open.

Trusted Web Activity (Experimental Release)

⚠️ Warning: Trusted Web Activity support in Auth0.Android is still experimental and can change in the future.

Please test it thoroughly in all the targeted browsers and OS variants and let us know your feedback.

Trusted Web Activity is a feature provided by some browsers to provide a native look and feel.

Trusted Web Activity

To use this feature, there are some additional steps you must take:

  • We need the SHA256 fingerprints of the app’s signing certificate. To get this, you can run the following command on your APK:
keytool -printcert -jarfile sample-debug.apk
  • The fingerprint has to be updated in the Auth0 Dashboard under Applications > Specific Application > Settings > Advanced Settings > Device Settings > Key Hashes
  • The app's package name has to be entered in the field above

Once the above prerequisites are met, you can call your login method as shown below to open your web authentication in Trusted Web Activity.

WebAuthProvider.login(account)
    .withTrustedWebActivity()
    .await(this)

Credentials Manager

This library ships with two additional classes that help you manage the Credentials received during authentication.

Basic

The basic version supports asking for Credentials existence, storing them and getting them back. If the credentials have expired and a refresh_token was saved, they are automatically refreshed. The class is called CredentialsManager.

Usage

  1. Instantiate the manager: You'll need an AuthenticationAPIClient instance to renew the credentials when they expire and a Storage object. We provide a SharedPreferencesStorage class that makes use of SharedPreferences to create a file in the application's directory with Context.MODE_PRIVATE mode.
val authentication = AuthenticationAPIClient(account)
val storage = SharedPreferencesStorage(this)
val manager = CredentialsManager(authentication, storage)
Using Java
AuthenticationAPIClient authentication = new AuthenticationAPIClient(account);
Storage storage = new SharedPreferencesStorage(this);
CredentialsManager manager = new CredentialsManager(authentication, storage);
  1. Save credentials: The credentials to save must have expires_at and at least an access_token or id_token value. If one of the values is missing when trying to set the credentials, the method will throw a CredentialsManagerException. If you want the manager to successfully renew the credentials when expired you must also request the offline_access scope when logging in in order to receive a refresh_token value along with the rest of the tokens. i.e. Logging in with a database connection and saving the credentials:
authentication
    .login("[email protected]", "a secret password", "my-database-connection")
    .setScope("openid email profile offline_access")
    .start(object : Callback<Credentials, AuthenticationException> {
        override fun onFailure(exception: AuthenticationException) {
            // Error
        }

        override fun onSuccess(credentials: Credentials) {
            //Save the credentials
            manager.saveCredentials(credentials)
        }
    })
Using coroutines
try {
    val credentials = authentication
        .login("[email protected]", "a secret password", "my-database-connection")
        .setScope("openid email profile offline_access")
        .await()
    manager.saveCredentials(credentials)
} catch (e: AuthenticationException) {
    e.printStacktrace()
}
Using Java
authentication
    .login("[email protected]", "a secret password", "my-database-connection")
    .setScope("openid email profile offline_access")
    .start(new BaseCallback<Credentials, AuthenticationException>() {
        @Override
        public void onSuccess(Credentials payload) {
            //Save the credentials
            manager.saveCredentials(credentials);
        }

        @Override
        public void onFailure(AuthenticationException error) {
            //Error!
        }
    });

Note: This method has been made thread-safe after version 2.8.0.

  1. Check credentials existence: There are cases were you just want to check if a user session is still valid (i.e. to know if you should present the login screen or the main screen). For convenience, we include a hasValidCredentials method that can let you know in advance if a non-expired token is available without making an additional network call. The same rules of the getCredentials method apply:
val authenticated = manager.hasValidCredentials()
Using Java
boolean authenticated = manager.hasValidCredentials();
  1. Retrieve credentials: Existing credentials will be returned if they are still valid, otherwise the refresh_token will be used to attempt to renew them. If the expires_at or both the access_token and id_token values are missing, the method will throw a CredentialsManagerException. The same will happen if the credentials have expired and there's no refresh_token available.
manager.getCredentials(object : Callback<Credentials, CredentialsManagerException> {
    override fun onFailure(exception: CredentialsManagerException) {
        // Error
    }

    override fun onSuccess(credentials: Credentials) {
        // Use the credentials
    }
})
Using coroutines
try {
    val credentials = manager.awaitCredentials()
    println(credentials)
} catch (e: CredentialsManagerException) {
    e.printStacktrace()
}
Using Java
manager.getCredentials(new BaseCallback<Credentials, CredentialsManagerException>() {
    @Override
    public void onSuccess(Credentials credentials){
        //Use the Credentials
    }

    @Override
    public void onFailure(CredentialsManagerException error){
        //Error!
    }
});

Note: In the scenario where the stored credentials have expired and a refresh_token is available, the newly obtained tokens are automatically saved for you by the Credentials Manager. This method has been made thread-safe after version 2.8.0.

  1. Clear credentials: When you want to log the user out:
manager.clearCredentials()

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public Github issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.


Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.

auth0.android's People

Contributors

aaguiarz avatar adamjmcgrath avatar bennycao avatar cocojoe avatar damieng avatar dependabot[bot] avatar dj-mal avatar evansims avatar fossabot avatar frederikprijck avatar hoix avatar hzalaz avatar jeffdgr8 avatar jimmyjames avatar joshcanhelp avatar jsalinaspolo avatar lbalmaceda avatar marcono1234 avatar nelsonmaia avatar nicbell avatar nolivermke avatar poovamraj avatar quibi-jlk avatar sre-57-opslevel[bot] avatar stevehobbsdev avatar syex avatar tlfilip avatar tm9k1 avatar tomhusson-toast avatar widcket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auth0.android's Issues

Proposal: CredentialsManager.getCredentials() should save renewed Credentials

CredentialsManager.getCredentials() is able to renew expired credentials and that is valuable. But this renewal is not persisted, so every time getCredentials() is called there is a network hit if the currently stored item has expired. Furthermore:

  • getCredentials() doesn't say if the returned item is from the storage or a renewed one.
  • hasValidCredentials() doesn't tell the difference neither.

So the only way I found for now would be to use an other storage unit to keep the last ExpiresAt for comparison with the returned credentials and in case of progression to do a saveCredentials().
I would prefer this process be done by the CredentialsManager.

Something like:

            @Override
            public void onSuccess(Credentials freshCredentials) {
/* + */         CredentialsManager.this.saveCredentials(freshCredentials);
                callback.onSuccess(freshCredentials);
            }

[Edit 28 Aug]
I discovered another issue with the call to renewAuth(refreshToken), which may introduce an infeasibility:
My freshCredentials has these unexpected properties:
getIdToken() is null.
getRefreshToken() is null.
getExpiresIn() is 86400, i.e. 24 hours ; I don't know where it comes from.

These ones seem correct:
getAccessToken() is a 16 chars string.
getType() is "Bearer".
getScope() is null.

Note: I also made a trial with my own duplicate of this part of source, to insert .addParameter("scope", "openid offline_access") before .start() and the result is the same.

My setting is setOIDCConformant(true).
The initial credentials comes from react-native-lock 0.6.1, with Lock 1.17.+, so the endpoints are /oauth/ro and /tokeninfo. The requested scope is the default one, i.e. "openid offline_access".
Is it possible that this refreshToken is not suitable for the oauth/token endpoint?

How to use MFA in native Auth0 calls

I'm trying to use MFA, when I loged in I got error mfa_required . that's correct

Next I'm sending MFA code

private static final String KEY_VERIFICATION_CODE = "mfa_code";
...
final Map<String, Object> params = new HashMap<>();
params.put(KEY_VERIFICATION_CODE, mfaCode);
request.addAuthenticationParameters(params);

this code is based on Auth0.Lock https://github.com/auth0/Lock.Android/blob/0faf10d5d93ed3c9560f2f47adc497261ff44dd7/lib/src/main/java/com/auth0/android/lock/LockActivity.java#L386
And my request has mfa_code parameter
{...."scope":"openid profile email","realm":"plutus","client_id":"...","username":"...","mfa_code":"586279"}

Next, I got again mfa_required, but I should receive mfa_invalid_code or successful response from the server.

How can use MFA with auth0?
We are using last version auth0 sdk and native client as auth0 application

Problem with Sign up and Log in

Hi! I have an a issue with signing up and logging in using Auh0 in android. Trying to sign up via client.signUp(email, password, connection).start() results me in failure, AuthenticationException says me there is 404 not found. When trying to sign up under the same email is also returning me 404 but the message is "Email already signed up". And web admin is seeing this user in database so we can say that user is really signed up. The same is happening with the login to the system. Getting 404 and nothing more. Can you explain please what is going wrong?

How to add user metadata on custom signup?

Hi, I am currently trying to add a phone number as custom metadata in my sign up as follows

` Map<String, Object> metadata = new HashMap<>();
metadata.put("contact_num", phoneNumber);

        authentication
                .signUp(email, pass,  "Username-Password-Authentication")
                .setScope("openid role")
                .addSignUpParameters(metadata)
                .start(new BaseCallback<Credentials, AuthenticationException>() {`

However this never seems to work. What am I doing wrong? Is this possible?

Can't logout from Webclient

Hello,
i use this code to start auth process :

auth0 = Utils.getAuth0();
        WebAuthProvider.init(auth0)
                .withScheme(getString(R.string.scheme))
                .start(this, callback);
And login/registration flow works perfectly. 

When try to logout - i can't find any way to do this.
Tried to save and clear with
credentialsManager.clearCredentials();
Yes, i know that i need to login in this way. But when i open WebAuthProvider again - it automatically login me to the app.

Used just email/password auth.
SDK version 'com.auth0.android:auth0:1.12.0'

Thanks for help.

java.lang.IllegalArgumentException: Empty key

0 javax.crypto.spec.SecretKeySpec. SecretKeySpec.java:96
1 com.auth0.android.authentication.storage.CryptoUtil.decrypt CryptoUtil.java:225
2 com.auth0.android.authentication.storage.SecureCredentialsManager.continueGetCredentials SecureCredentialsManager.java:208
3 com.auth0.android.authentication.storage.SecureCredentialsManager.getCredentials SecureCredentialsManager.java:175

App crashes at the very first launch after installation, but works on the following launches.

WebAuthProvider's callback URI uses https

After following following this WebAuthProvider guide, the browser authenticates and closes, but instead of going back to the app an intent picker is shown, prompting the user to pick whether they'll open the callback in our app or in the browser:
device-2016-12-08-141135

This is an issue because the average user is likely to get confused by this dialog, and if the browser is set as the default handler for the callback this way, there's no easy way for them to reset the default.

Currently when using a WebAuthProvider, the callback URI is of the form: https://{AUTH0_DOMAIN}/android/{BUNDLE_NAME}/callback.
However, for Android to know to open our app on the first try, the callback URI should be of the form: {BUNDLE_NAME}://{AUTH0_DOMAIN}/android/{BUNDLE_NAME}/callback.

Currently, it's working on iOS, with the bundle identifier as the URI protocol.

Silent authentication error is swallowed in OAuthManager

We are attempting to perform silent authentication following the instructions here https://auth0.com/docs/api-auth/tutorials/silent-authentication, and are seeing an issue with how the error response is handled.

Some background: we have a custom hosted login page in Auth0 and are using the WebAuthProvider.init().start() call to present it from our Android client. We added the parameter "prompt" with value of "none" using the withParameters method provided by WebAuthProvider.Builder.

When the prompt=none parameter is used, and we are attempting to log in for the first time, we see an error response coming back from Auth0 with a value of "login_required" (which is what we expect). This error is handled by the OAuthManager class, and inside assertNoError (line 165 in OAuthManager), the error is swallowed and an AuthenticationException is thrown with a value of "a0.invalid_configuration". The a0.invalid_configuration error is what is passed back to our onFailure callback in the client.

Ideally we would like to get the "login_required" error value (and any other silent auth error responses https://auth0.com/docs/api-auth/tutorials/silent-authentication#error-response) in the onFailure callback, so we know to make the WebAuthProvider.init().start() call without prompt=none parameter.

If it helps, we are seeing the correct error response "Login required" when using the Auth swift library for iOS. Please advise.

Auth0Exception and SocketTimeoutException when calling renewAuth not OIDC Conformant

I'm the developer of an app that is available at the Play Store and I received some crash reports that I couldn't reproduce, all related to the renewAuth method.

The app uses the idToken to perform requests to our own back-end and the accessToken to authenticate with Auth0. Having that in mind, sometimes I need to refresh both tokens.

To refresh the accessToken I call the renewAuth with OIDC Conformant set to true, the request returns as a success and I save the refreshed token.
Then, when I refresh the idToken performing a request to renewAuth without setting OIDC Conformant (false as default), it worked as expected in my tests and uses, but some users received an AuthenticationException or SocketTimeoutException.

I created gists with the Stack Traces of both exceptions, here for AuthenticationException and here for SocketTimeoutException.

This is the link for the app in the play store: https://play.google.com/store/apps/details?id=org.singularityu.suhub.android

I understand that the SocketTimeoutException probably is caused by a bad network connection, but should this performs a crash?

The AuthenticationException I don't have idea why it happen.

Any help with theses crashes will be very appreciated 🙂

NPE in AuthenticationActivity

We're experiencing the following crash. It seems that a null check is needed here:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {tv.fubo.mobile/com.auth0.android.provider.AuthenticationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.os.Bundle.getParcelable(java.lang.String)' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3521)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.os.Bundle.getParcelable(java.lang.String)' on a null object reference
at com.auth0.android.provider.AuthenticationActivity.launchAuthenticationIntent(AuthenticationActivity.java:98)
at com.auth0.android.provider.AuthenticationActivity.onResume(AuthenticationActivity.java:76)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1255)
at android.app.Activity.performResume(Activity.java:6495)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3510)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Incomplete Management API

The SDK implements only a small portion of the Management API features.
It would be great if it implemented the entire set of calls in order to be really usable.

Mismatch between `Client Quick Settings` instruction and ReadMe on Auth0.Android

Hello Auth0,

Thanks for your support on Android.
On setting up the client for Android (Native app), I found there is something not synced between the Client Quick Start guide (see attached image)
screen shot 2017-12-08 at 5 16 21 pm

and the guide on ReadMe of this project.

In details,

The Quick Start guide asks us to prepare 2 string resources value:

<resources>
    <string name="com_auth0_client_id">my-client-id</string>
    <string name="com_auth0_domain">my-domain.auth0.com</string>
</resources>

Then, if we add the follow code snippet into app.gradle to add Manifest placeholder:

  manifestPlaceholders = [auth0Domain: "@string/auth0_domain", auth0Scheme: "https"]

And compile the project, we will get the following error:

screen shot 2017-12-08 at 5 20 36 pm

Fix work for me

I change the string resource names into:

 <string name="auth0_client_id">my-id</string>
 <string name="auth0_domain">my-domain.auth0.com</string>

Now, project can be build and run successfully

renewAuth cannot refresh access token/id token

I'm trying to test renewing with a refresh token.

        client.renewAuth(AccountManager.getCredentials(this).getRefreshToken())
                .addParameter("scope", "openid profile email")
                .start(authenticationCallback);

But getting either of the below errors in the onFailure callback.
Grant not found, cannot refresh access token
Unsupported grant type: refresh_token

Account > Advanced > OAuth 2.0 API Authorization is turned on.

Any thoughts?

AuthenticationException constructor throws ClassCastException

This is the latest build I believe (v1.3.0).

When I allow the Auth0 validation to occur instead of my own, (specifically for passwords) I get an exception that I cannot handle without overriding that class. This seems like it shouldn't be happening, so let me know if it looks suspicious, however, I am seeing this issue on 1.0.0 as well as 1.3.0

Judging by where I get to whilst debugging, it looks like the offending line is (AuthenticationException 74):

this.description = (String) (this.values.containsKey(DESCRIPTION_KEY) ? this.values.get(DESCRIPTION_KEY) : this.values.get(ERROR_DESCRIPTION_KEY));

here is the stack trace:
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to java.lang.String at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:23) at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:9) at com.auth0.android.request.internal.BaseRequest.parseUnsuccessfulResponse(BaseRequest.java:133) at com.auth0.android.request.internal.SimpleRequest.onResponse(SimpleRequest.java:65) at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

here's what's inside the values object:
values = {LinkedTreeMap@7884} size = 6
0 = {LinkedTreeMap$Node@7909} "name" -> "PasswordStrengthError"
1 = {LinkedTreeMap$Node@7910} "message" -> "Password is too weak"
2 = {LinkedTreeMap$Node@7911} "code" -> "invalid_password"
3 = {LinkedTreeMap$Node@7912} "description" -> " size = 2"
4 = {LinkedTreeMap$Node@7913} "policy" -> "* At least 6 characters in length"
5 = {LinkedTreeMap$Node@7914} "statusCode" -> "400.0"

Let me know if I can provide any more information or be any more help

renewAuth returns null.

Hi.

The version I am using is 'com.auth0.android:lock:2.5.0'. I am logging in successfully using the Lock UI, but later when I try to refresh the token it is returning a null value.

Logging in:
accessToken: aBm3tb2DYBRpjb6l
refreshToken: REDACTED

After running the renewAuth(refreshToken) I am always getting back null?
accessToken: null
refreshToken: null

Chrome Custom Tabs should have ability to adjust

It's great that you have added support for Chrome Custom Tabs but we really need ability to alter in it's builder. I'd love to change color and display title instead of url.
Any plans on adding that or ways to nicely hack it?

Cannot minimize application with opened Chrome Tabs

If during login process user minimize application and restore it we will get an error in AuthCallback.onFailure(AuthenticationException) method with

exception = {AuthenticationException@4900} "com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server."
code = "invalid_request"
description = "Missing required parameter: code"
statusCode = 0
values = {HashMap@4908} size = 2
0 = {HashMap$HashMapEntry@4917} "error" -> "invalid_request"
1 = {HashMap$HashMapEntry@4918} "error_description" -> "Missing required parameter: code"
backtrace = {Object[10]@4909}
cause = {AuthenticationException@4900} "com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server."
detailMessage = "An error occurred when trying to authenticate with the server."

it's important for us to handle those situations correctly because if you are trying to log in with mobile using Norwegian BankID user is prompt with system Acitivty (launched from USSD code I think) in which user must enter some number and when it's closed I'm getting that error.

It's easily to reproduce in sample 00-login. Just click "show log in" then minimize app and restore.

Wrong path for passwordless login?

For this function:

            authentication
                    .loginWithEmail(username, password, "email")
                    .setScope("openid offline_access")
                    .start(new BaseCallback<Credentials, AuthenticationException>() {
                        @Override
                        public void onSuccess(Credentials payload) {
                            //Logged in!
                            Log.d("auth0", String.valueOf(payload));
                            credentialsManager.saveCredentials(payload);
                        }

                        @Override
                        public void onFailure(AuthenticationException error) {
                            //Error!
                            Log.d("auth0", String.valueOf(error));
                        }
                    });

I got this error:

07-12 22:35:15.734 10348-10639/XXX D/OkHttp: --> POST https://XXX.auth0.com/oauth/ro HTTP/1.1
    Content-Type: application/json; charset=utf-8
    Content-Length: 175
    Auth0-Client: XXXX
    Accept-Language: hu_HU
    {"password":"XXXXXX","scope":"openid offline_access","client_id":"XXXXXX","username":"XXXXXX","connection":"email","grant_type":"password"}
    --> END POST (175-byte body)
07-12 22:35:15.834 10348-10639/XXX D/OkHttp: <-- HTTP/1.1 404 Not Found (102ms)
    Date: Thu, 12 Jul 2018 20:35:15 GMT
    Content-Type: text/plain; charset=utf-8
    Content-Length: 9
    Connection: keep-alive
    X-Auth0-RequestId: abfe27a2f73626edf851
    X-RateLimit-Limit: 10
    X-RateLimit-Remaining: 9
    X-RateLimit-Reset: 1531427716
    Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    OkHttp-Sent-Millis: 1531427715747
    OkHttp-Received-Millis: 1531427715837
    Not Found
    <-- END HTTP (9-byte body)
07-12 22:35:15.834 10348-10639/XXX D/auth0: com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server.

Changing this in AuthenticationAPIClient.java:

private static final String RESOURCE_OWNER_PATH = "ro";

To this:

private static final String RESOURCE_OWNER_PATH = "token";

fixed it. Is this the correct solution?

Thanks

Custom UI and passwordless login(Phone no + code): Authentication failure

My code was working fine for 1.4.0 library. Then I upgraded to 1.7 0 library and authentication failed but now when again I degraded to auth 1.4.0 library. Authentication is still failing
Failed to request a passwordless Code/Link: An error occurred when trying to authenticate with the server.
com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server.
at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:23)
at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:9)
at com.auth0.android.request.internal.BaseRequest.parseUnsuccessfulResponse(BaseRequest.java:137)
at com.auth0.android.request.internal.SimpleRequest.onResponse(SimpleRequest.java:68)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)

Error: Missing username parameter

Hi, I have generated a one time code using AuthenticationAPIClient, and I am calling authAPIClient.loginWithPhoneNumber(phonenumber,code)

But this is failing, and exception says: code = invalid_request description= missing username parameter

Is there something I am missing?
(I am using this library: 'com.auth0.android:auth0:1.6.0')
I have seen that everytime I call generate one time token, it gives me a new token (regardless of whether previous token was used or not, so does this mean user need to pass in latest token received or any of previous unused token can be used).

Scenario:

  1. User generates 1st one time token.
  2. Token not received in few mins (sms delivery delays from network provider etc etc).
  3. User generates 2nd one time token.
  4. User receives 1st one time token.
  5. User goes and inputs this 1st one time token to login.
  6. Will this token succeed in logging in? or User need to wait for 2nd token to deliver in sms and try that one?

Thanks

AuthenticationException has no methods for invalid tokens

The AuthenticationException provides different methods for checking the status code, e.g. isPasswordLeaked().

I am missing methods for token validity, e.g.:

  • Invalid id token
  • Expired id token
  • Invalid refresh token
  • Expired refresh token

Also for android it might be useful to somehow have a method like isNetworkError(), as this could then be treated separately (e.g. the local credentials should not be deleted in this case).

NPE inside AuthenticationActivity.onResume() when webview is opened not in chrome

Hey guys, this is causing some serious issues for us...

Fatal Exception: java.lang.RuntimeException
Unable to resume activity {com.linuxacademy.linuxacademy/com.auth0.android.provider.AuthenticationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.os.Bundle.getParcelable(java.lang.String)' on a null object reference

Caused by java.lang.NullPointerException
  |com.auth0.android.provider.AuthenticationActivity.launchAuthenticationIntent (AuthenticationActivity.java:96)
| com.auth0.android.provider.AuthenticationActivity.onResume (AuthenticationActivity.java:74)
 | android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1277)
 | android.app.Activity.performResume (Activity.java:7088)
 | android.app.ActivityThread.performResumeActivity (ActivityThread.java:3768)
 | android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3832)
 | android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2994)
 | android.app.ActivityThread.-wrap14 (ActivityThread.java)
 | android.app.ActivityThread$H.handleMessage (ActivityThread.java:1631)
 | android.os.Handler.dispatchMessage (Handler.java:102)
 | android.os.Looper.loop (Looper.java:154)
 | android.app.ActivityThread.main (ActivityThread.java:6682)
 | java.lang.reflect.Method.invoke (Method.java)
 | com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
 | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)

I don't know if it's the cause every time for us, but I know how to recreate this crash.

  1. Download firefox or some other browser (firefox for sure works)
  2. Set firefox as default browser
  3. Open app, launch auth0 webview. Notice webview opens in different application (not in same application like a chrome webview would)
  4. While webview is open, close launching application
  5. Finish login in webview
  6. Crash

This is the only way I've been able to reproduce this crash that we're getting. The only thing that I can think of is that all of these crashes are coming from people who aren't using chrome as their default browser, and have a ton of stuff going on in the background... so when they open the webview the launching application is closed because there isn't enough system memory. Doesn't make a ton of sense though since that would be the "most recent" application...

NPE when resuming AuthenticationActivity

Has anyone else encountered this error?

After calling WebAuthProvider.init(auth0)...start() to display the chrome tab view simply tapping "Back" or the "Close" button results in a crash:

09-29 14:41:39.355 11231 11231 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.dat.template/com.auth0.android.provider.AuthenticationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3645)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3685)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1643)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:105)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6541)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.jwt.JWT.splitToken(JWT.java:209)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.jwt.JWT.decode(JWT.java:200)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.jwt.JWT.<init>(JWT.java:40)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.provider.OAuthManager.assertValidNonce(OAuthManager.java:186)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.provider.OAuthManager.resumeAuthorization(OAuthManager.java:116)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.provider.WebAuthProvider.resume(WebAuthProvider.java:361)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.provider.AuthenticationActivity.deliverSuccessfulAuthenticationResult(AuthenticationActivity.java:117)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at com.auth0.android.provider.AuthenticationActivity.onResume(AuthenticationActivity.java:78)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1354)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.Activity.performResume(Activity.java:7079)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3620)
09-29 14:41:39.355 11231 11231 E AndroidRuntime: 	... 8 more

JsonParseException: credentials json is not a valid json object

When doing some edge case testing we found this crash in the Auth0 Lib.
To replicate we proxy the login API response from Auth0, and provide a malformed or empty {} response.
I am aware this may never happen and we can catch the crash in a try, however wanted to raise as either a known issue, or for the lib to handle and respond according.
I will try and write a PR when I get time

                  Process: ***, PID: 8999
                  com.google.gson.JsonParseException: credentials json is not a valid json object
                      at com.auth0.android.request.internal.CredentialsDeserializer.deserialize(CredentialsDeserializer.java:20)
                      at com.auth0.android.request.internal.CredentialsDeserializer.deserialize(CredentialsDeserializer.java:15)
                      at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
                      at com.google.gson.TypeAdapter.fromJson(TypeAdapter.java:260)
                      at com.auth0.android.request.internal.SimpleRequest.onResponse(SimpleRequest.java:75)
                      at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
                      at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                      at java.lang.Thread.run(Thread.java:761)```

IllegalArgumentException: Service not registered: when unbinding CustomTabsController

I am getting a consistent crash in my android emulator when trying to integrate Auth0 into my app. I am using last version of the library (1.13.1).

After some time debugging the issue I think I get a basic understanding of what's going on.

CustomTabsController define these methods

/**
     * Attempts to bind the Custom Tabs Service to the Context.
     */
    public void bindService() {
        Log.v(TAG, "Trying to bind the service");
        Context context = this.context.get();
        boolean success = false;
        if (context != null && preferredPackage != null) {
            success = CustomTabsClient.bindCustomTabsService(context, preferredPackage, this);
        }
        Log.v(TAG, "Bind request result: " + success);
    }

    /**
     * Attempts to unbind the Custom Tabs Service from the Context.
     */
    public void unbindService() {
        Log.v(TAG, "Trying to unbind the service");
        Context context = this.context.get();
        if (context != null) {
            context.unbindService(this);
        }
    }

When I am starting a WebAuthProvider, an AuthenticationActivity is presented to the user, and this activity is calling the method bindService. For some reason, preferredPackage is null in my emulator and success = CustomTabsClient.bindCustomTabsService(context, preferredPackage, this); is not getting called. Then, when activity is destroyed, unbindService is called and my app crashes because context is trying to unbind a service that was never bind.

I believe the if clause should match in both methods so if it doesn't enter in the first one to bind the service, it doesn't;t enter in the second one either to unbind it, and then you don't get calls unbalanced.

I have tried with previous version of the library (1.13.0), as this change has been introduced recently (6 days ago), and it is not crashing anymore in my emulator.

Cancelling web authentication doesn't fire failure event

After the changes in #120, when a user cancels the web authentication, the OAuth manager would recognize that the AuthorizeResult is invalid and return false straight away, without calling onFailure in the callback.

This causes problem if the client app is stuck, waiting for the result of the Authentication, as there is no other way to detect whether the authentication process has completed or not.

Is it possible to add callback.onFailure(new AuthenticationException("Invalid Authorize Result")) before returning false in the following blocks?

And also adding an else clause to trigger the callback in AuthenticationActivity

So that the client app would know the web authentication process has completed without success?

Set isOIDCConformant to true by default or document it

Today I spent some time trying to integrate the SDK and wanted to start with the basic creation of new users:

AuthenticationAPIClient(context)
                    .signUp(email, password, "Username-Password-Authentication")
                    .start(object : BaseCallback<Credentials, AuthenticationException> {})

which always resulted in onFailure with a 404.

After some debugging I found out signUp() calls loginWithResourceOwner() which uses the endpoint /oauth/ro, which seems to be deprecated and non-existing, resulting in the 404.

By chance I found the method public void setOIDCConformant(boolean enabled) which instantly solved the problem when calling it with enabled = true.

I thereby suggest to set this value to true by default, as it seems useless if it otherwise calls an API that is deprecated and cannot be enabled for new clients anymore or at least document it in your README to call this method when creating the Auth0 instance.

Occasionally after login Auth0 doesn't redirect

I'm not even sure if that is an Auth0.Android issue. However after finishing login process sometimes user is stuck in chrome tabs.
32108508-39ca60ce-bb32-11e7-8763-9ac79ce392f5
It happens both on production and testing environment. We are using integration to Norwegian BankID.

Make manifestPlaceholders optional

Hi,

I am trying to upgrade form the 1.8.0 version to the 1.13.0 version, with this last version a manifestPlaceholders configuration is required. But from what I understand it is only used for webAuth0 which I don't use for my project.

Is it possible please to make it optional so I don't need to put dummy configuration or remove RedirectActivity from my manifest ?

Thanks

Support TLSv1.2 on older Android API

Auth0 supports down to API 15 but as detailed here TLSv1.1 and v1.2 are not used by default on older APIs. Potential solutions are detailed here, here and here.

Currently by using the Auth0 API you are unable to support devices using APIs lower than 21 with a backend that enforced TLSv1.2. Because of this the Auth0 android library is not very useful to any apps that plan on supporting older devices in a secure manner.

java.lang.SecurityException in CustomTabsController

Hello!
I have a strange crash in the app while trying to log in via Google on Xiaomi Mi A1. Could you please help me why it can be?
build.gradle
implementation("com.auth0.android:lock:2.8.3") { exclude group: 'com.android.support' }

Fatal Exception: java.lang.SecurityException: Binder invocation to an incorrect interface at android.os.Parcel.readException(Parcel.java:1942) at android.os.Parcel.readException(Parcel.java:1888) at android.support.customtabs.ICustomTabsService$Stub$Proxy.warmup(ICustomTabsService.java:224) at android.support.customtabs.CustomTabsClient.warmup(CustomTabsClient.java:171) at com.auth0.android.provider.CustomTabsController.onCustomTabsServiceConnected(CustomTabsController.java:78) at android.support.customtabs.CustomTabsServiceConnection.onServiceConnected(CustomTabsServiceConnection.java:32) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1631) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1660) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:172) at android.app.ActivityThread.main(ActivityThread.java:6637) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Can't logout from Webclient

Hello,
I am using this code to start auth process :

Auth0 auth0 = new Auth0(AppConfig.auth0clientId, AppConfig.auth0domain);

auth0 = Utils.getAuth0();
WebAuthProvider.init(auth0)
.withParameters(parameters)
.withScheme(getString(R.string.scheme))
.withScope(Config.Auth0.scopeValue)
.start(this, callback);

Parameters contains "prompt": "login"

And login/registration flow works perfectly.
When try to logout - it automatically login me to the app.

Used just email/password auth.
SDK version 'com.auth0.android:auth0:1.12.0'

NPE in AuthenticationException

Hello,

In our crashlytics logs some users are getting an NPE.
It starts by having a null mapPayload from the gson parsing here:
https://github.com/auth0/Auth0.Android/blob/master/auth0/src/main/java/com/auth0/android/request/internal/BaseRequest.java#L137

And the crash happens when creating a new HashMap from a null-object here:
https://github.com/auth0/Auth0.Android/blob/master/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.java#L76

This is the log:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.Map.size()' on a null object reference
       at java.util.HashMap.(HashMap.java:253)
       at com.auth0.android.authentication.AuthenticationException.(AuthenticationException.java:76)
       at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:23)
       at com.auth0.android.request.internal.AuthenticationErrorBuilder.from(AuthenticationErrorBuilder.java:9)
       at com.auth0.android.request.internal.BaseRequest.parseUnsuccessfulResponse(BaseRequest.java:137)
       at com.auth0.android.request.internal.SimpleRequest.onResponse(SimpleRequest.java:68)
       at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
       at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)

Would it make sense to guard against it in such a way?:

    public AuthenticationException(Map<String, Object> values) {
        this(DEFAULT_MESSAGE);
        if(values == null) {
                  this.code = UNKNOWN_ERROR;
                  return;
        }
        this.values = new HashMap<>(values);
        ....

Please let me know your thoughts and how this could be resolved,
Thanks alot!

Edit: I noticed there was a similar issue before (#137). Is this somehow related?

Inconsistent behaviour compared to iOS Auth0 when pressing back button

Using webauth on iOS, when the user press the Done button and the web controller is closed the callback is called with an error saying that user cancelled auth.

On Android though, the back button is not handled by the activity and the user is brought back to the activity which triggered the webauth but the callback is not called. How is the origin activity supposed to know that the user pressed back to somehow "cancel" the auth process ?

IllegalArgumentException in CustomTabsClient

We're experiencing the following crash in production:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {tv.fubo.mobile/com.auth0.android.provider.AuthenticationActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.support.customtabs.action.CustomTabsService }
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3535)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3575)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.support.customtabs.action.CustomTabsService }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1347)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1459)
at android.app.ContextImpl.bindService(ContextImpl.java:1427)
at android.content.ContextWrapper.bindService(ContextWrapper.java:636)
at android.support.customtabs.CustomTabsClient.bindCustomTabsService(CustomTabsClient.java:70)
at com.auth0.android.provider.CustomTabsController.bindService(CustomTabsController.java:97)
at com.auth0.android.provider.AuthenticationActivity.launchAuthenticationIntent(AuthenticationActivity.java:111)
at com.auth0.android.provider.AuthenticationActivity.onResume(AuthenticationActivity.java:76)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
at android.app.Activity.performResume(Activity.java:6861)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3512)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3575)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

renewAuth doesn't return valid tokens

Hi all!

I'm trying to use the new /oauth/token endpoints with the 1.5 version of this library.

I can successfully login and receive correct access_token, id_token, and refresh_token but when I call renewAuth I am not getting back any valid tokens.

I am calling .setOIDConformant(true); before any calls to the Auth0 APIs and I have the flag switched on in the Auth0 Management Console for the Android Client.

authClient.renewAuth(credentials.getRefreshToken())
    .addParameter("scope", "opened name email profile tribalId app_metadata offline_access")
    .start(authenticationCallback)

The Credentials object that I get in the callback has accessToken set to what seems to be an old APIv1 token that is 16 characters long and both the idToken and refreshToken are set to null with the type set to Bearer.

Any help would be much appreciated.

Cheers!

Null HashMap in AuthenticationException

Fatal Exception: java.lang.NullPointerExceptionAttempt to invoke interface method 'int java.util.Map.size()' on a null object reference Raw Text
--
  | java.util.HashMap. (HashMap.java:253)
  | com.auth0.android.authentication.AuthenticationException. (SourceFile:76)
com.auth0.android.request.internal.AuthenticationErrorBuilder.from (SourceFile:23)
--
  | com.auth0.android.request.internal.AuthenticationErrorBuilder.from (SourceFile:9)
  | com.auth0.android.request.internal.BaseRequest.parseUnsuccessfulResponse (SourceFile:137)
  | com.auth0.android.request.internal.SimpleRequest.onResponse (SourceFile:68)

Missing required parameter: code

I'm getting an AuthenticationException in my app after following your instructions to create a boilerplate authorization flow. Strangely, I got the sample app working with the same client ID and domain. With my own app, I have it set up the exact same way (as far as I can tell -- I even tried copying and pasting the Activity from the sample app, with no luck), but it fails after redirecting back to the app (after the Auth0 login page). The Auth0 logs claim I'm using development keys to connect when I try with my own app (I'm not, as far as I'm aware). Any idea what's going on here? I've followed all instructions in the README, and double-checked my client ID/domain and callback URL. I've tried to break the sample app by including all the Gradle dependencies that exist in my app.

Custom Rule errors are not available in the exception

When using WebAuthProvider to log in and a Rule I've created on my dashboard fails to process the request, the custom error I return it's not available in the AuthenticationException description.

I would expect that the exception returns true when calling exception.isRuleError() and also that the exception.getDescription() in that case returns the message that I define in my Rule script.

The line where this decision is made: https://github.com/auth0/Auth0.Android/blob/master/auth0/src/main/java/com/auth0/android/provider/OAuthManager.java#L165

Upgrade to OKHttp3?

Hey, I was wondering if there is any reason you are still on OKHttp 2 instead of 3?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.