Getting an authorization code using Android SDK

Hey,

I’m trying to implement the authorization code flow where an Android app requests an authorization code and and gives it to the Auth0 app on another device (a BLE peripheral in this case).

That device, in turn, will use the code to obtain a token.
I specified .withResponseType(ResponseType.CODE) when calling login, but it looks like the API will do anything it can to give me Credentials instead.

Is there an API in the Auth0 Android SDK which will give me an authorization code?

Thanks, Gilad.

This is an inelegant solution, but I overrode the intent-filter set up by the filter, caught the intent, and parsed it manually.

I hope that this functionality will be available in the SDK some day.

<activity android:name=".RedirectActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="@string/com_auth0_domain"
                android:pathPrefix="/android/${applicationId}/callback"
                android:scheme="my_scheme" />
        </intent-filter>
    </activity>

The code for RedirectActivity was copied from the SDK:

public class RedirectActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceBundle) {
        super.onCreate(savedInstanceBundle);
        Intent intent = new Intent(this, MyActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        if (getIntent() != null) {
            intent.setData(getIntent().getData());
        }
        startActivity(intent);
        finish();
    }
}