s3i_flutter 0.1.0 s3i_flutter: ^0.1.0 copied to clipboard
A library that makes it easy to communicate with the S³I (Smart Systems Service Infrastructure of the KWH4.0).
S³I Flutter
A library that makes it easy to communicate with the S³I
(Smart Systems Service Infrastructure of the Kompetenzzentrum Wald und Holz 4.0)
🚧 currently under construction 🚧
Installing #
Add it to your pubspec.yaml
file:
dependencies:
s3i_flutter: ^0.1.0
Install packages from the command line
flutter packages get
If you like this package, consider supporting it by giving a star on GitHub and a like on pub.dev ❤️
About S³I and KWH4.0 #
If you are not familiar with the S³I concepts, please consider reading the KWH4.0-Standpunkt.
For further information see the KWH Glossar and the other Standpunkte.
Usage #
For a basic example application see the example.
Setup Auth #
Create a ClientIdentity
used by your app. Please contact the KWH4.0 to get an app specific client.
final clientIdentity = ClientIdentity(<CLIENT-ID>, <CLIENT-SECRET>);
Now you can pass this to an AuthenticationManager
of your choice.
See here for a list of some implementations.
In this example we use the OAuthProxyFlow
. You can specify some scopes to add specific claims in your token.
final authManager = OAuthProxyFlow(clientIdentity,
openUrlCallback: (uri) {debugPrint("Please visit:" + uri.toString());},
onAuthSuccess: () {debugPrint("Auth succeeded");},
scopes: ["group", "offline_access"]);
Last but not least you should use this AuthenticationManager
-Instance to create a S3ICore
-Instance. Now you could work with the S3I
.
final s3i = S3ICore(authManager);
If you want to assure that the user is authenticated before going on with other requests
you could trigger the auth process explicit by calling the login()
function:
try {
await s3i.login();
} on S3IException catch (e) {
debugPrint("Auth failed: " + e.toString());
}
Send Requests to the directory #
If the S3ICore
-Instance is ready to use you can receive information about a specific thing by calling getThing()
.
If you don't need the whole thing it's recommended to use a FieldQuery
so you only receive a part of the entry
which is faster and safes network data.
try {
var thing = await s3i.getThing(<THING_ID>, fields: FieldQuery(["attributes/ownedBy"]));
} on S3IException catch (e) {
debugPrint("Request Thing failed: " + e.toString());
}
Project Structure #
TODO: s3i core / entry
directory #
auth #
The auth
folder includes classes which are used to authenticate a user/client in the S3I.
The S3ICore
needs a valid instance of a AuthenticationManager
to work.
Currently there is only one implementation available: OAuthProxyFlow
.
This implementation of the AuthenticationManager
uses the S3I-OAuthProxy to obtain an access and refresh token.
But it doesn't refreshes the tokens automatically, only only if getAccessToken
is called and the accessToken
is expired.