In need for basic info how to use safe_client_libs (language agnostic)

I am trying to create simple app in Java using safe_app_java and respectively safe_client_libs (in mock mode).

I’ve managed to connect unauthorized app but when trying to create authorized app I am having few problems.

First problem: I cannot find info how to send authorization request. I’ve guessed that I need to use encodeAuthReq() function but when I call it I am getting this error:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error(JavaException, State { next_error: None, backtrace: None })', /checkout/src/libcore/result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
fatal runtime error: failed to initiate panic, error 5

Is there a tutorial which explains how to get authorization and connect authorized app (preferably c#, Rust)?

Also: where the authenticator process lives? Shall I start it separately somehow or it is started automatically in the native part?
I was thinking that the authenticator is separate service but then saw this RFC New Auth Flow (https://github.com/maidsafe/rfcs/blob/master/text/0046-new-auth-flow/0046-new-auth-flow.md).

Hi,

It’s hard to tell what could be the reason without looking at source code.
Could you please share it somewhere on GitHub or in Gist?

You can implement your own Authenticator if you wish to do so, but I guess you’re interested in creating just Apps so I would suggest just using SAFE Browser for this purpose: it already implements the Authenticator protocol with the user’s interface. So you don’t need to do anything else, just construct your app authorisation request and send it via the system_uri library (which basically abstracts away your operating system’s open function, opening a custom-generated URI in a registered protocol handler - that is, SAFE Browser).

Hi,
Thank you for your reply.
The code is here: https://gist.github.com/ogrebgr/bccb1526dfadee46f8b992deebfc719e.
The error is produced when BaseSession.getAuthRequest() is called.

About the system_uri lib: is it bundled with safe_app_java or I shall clone it, build, create bindings, etc?
Can you show me example how to call it from java?

Btw, I DMed with @Krishna and he pointed me to your branch (https://github.com/nbaksalyar/safe_client_libs/tree/bindgen). I was wondering:

  1. What tool do you use to generate the java classes and where are the config settings for it?
  2. Krishna mentioned that it is still not merged to master, is there something that is preventing the merge?

At present, the best would be to check the test cases I was working on. There was an error with the Structs getting Marshalled between the FFI layer. That is fixed in the branch that I had linked to you. I couldn’t manage my time last week (Thursday/Friday) to get the bindings updated in the master branch. I will do it tomorrow and update here. Will also try to document on how to build the bindings etc step wise and then pass it to you.

The test cases are using a helper function to create a test, while in the new bindings we will have to try integrating authenticator APIs too for more flexible test suite. Am sure that will help you understand the end to end flow of the APIs.

It is a rust crate safe_bindgen that is used to build the bindings. That is part of the safe_client_libs and the config is specified as part of the build command itself.

We are planning to have the client_libs to be able to generate binding code for csharp and java. We will have to get the Java binding generation to follow a similar convention as like csharp so that both make use of the same package scripts. The binding generation code is being evolved and will be merged soon.

@nbaksalyar, can be able to provide more info here on where it stands.

To keep the Java API rolling, I will first update to the latest bindings and update the upstream. Once that is done, I will ping here so that you can give it a try.

I will also pass a simple to doc to follow so that you can try generating the bindings yourself.

Sorry, I totally missed that. Did not paid attention that is separate repo.

Thanks. Looking forward to use it.

No problem at all. Things are scattered at this point of time. It is certainly difficult to keep a track of these. I am trying to squeeze my time to get these bindings updated. Even if the tests are failing I will try to get the master branch updated with the README stating it is WIP and not ready for integration with apps. We can prolly start planning it from there and take it forward.

2 Likes