How to start unregistered session on Android/Java

Following the tutorial I am able to authenticate, create mutable data, etc., but when I try to create unregistered session in order to access the newly created data as anonymous user I am having trouble getting it to work.
I am using code like this:

@OnClick(R.id.btn_connect)
void onClickBtnConnect() {
    try {
        Client.load(this);

        CompletableFuture<Request> connReq = Session.getUnregisteredSessionRequest("com.bolyartech.safenettest");

        final String AUTH_URL_PREFIX = "safe-auth://";
        String url = AUTH_URL_PREFIX + "com.bolyartech.safenettest" + '/' + connReq.get().getUri();
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        startActivity(intent);

    } catch (ExecutionException | InterruptedException e) {
        e.printStackTrace();
    }

}

Authenticator is started, shows the “Auth” dialog but with empty fields for app id, etc. When “Allow” button is pressed exception is thrown:

android.runtime.JavaProxyThrowable: System.UriFormatException: Invalid URI: The URI is empty.

Seems like my request to the Authenticator is not properly formated.
How to create unregistered session? Are there examples (programming language does not matter) where I can see how it is supposed to be done?

2 Likes

Hi @ogrebgr ,
Thanks for reporting the issue, this is a bug on the SafeAuthenticator. In the current implementation an unregistered request sent to the authenticator is required to be in the following format
safe-auth://<appID>/<encodedString>/unregistered

we have fixed this in the next iteration, if you do need an apk with this resolved do let me know

6 Likes

Hey @ogrebgr

We’ve just updated the SafeAuthenticator. You can find the latest release here, an unregistered request format would be the same as every other authorization request sent to the authenticator i.e safe-auth://<appID>/<encodedString>

We do not support the safe-auth://<appID>/<encodedString>/unregistered format anymore.

4 Likes

Thanks for the update @AshwinKumar :slight_smile:

4 Likes