🔒

Authentication

First-time authentication - Save credentials

Flutter
React Native
You can use your email/password combination initially to retrieve an OAuth1 token/secret combination which you can use to reauthenticate when reloading the application. You can use any persistent storage system such as https://pub.dev/packages/localstorage.
import 'package:flutter_fibricheck_sdk/flutter_fibricheck_sdk.dart';
​
_storage = new LocalStorage('my_app');
_sdk = FLFibriCheckSdk.client("consumerKey", "consumerSecret");
​
var res = await _sdk.authenticateWithEmail(
ParamsOauth1WithEmail(email: "email", password: "password"),
(consents) {
_onConsentNeeded(consents);
},
);
//save token
storage.setItem('token', res.token);
//save token secret
storage.setItem('tokenSecret', res.tokenSecret);
Afterwards you can use the stored tokenData to authenticate.
​
var res = await _sdk.authenticateWithToken(
ParamsOauth1WithToken(token: storage.getItem('token'), tokenSecret: storage.getItem('tokenSecret')), (consents) {
_onConsentNeeded(consents);
},)
You can use your email/password combination initially to retrieve an OAuth1 token/secret combination which you can use to reauthenticate when reloading the application. In this example @react-native-async-storage/async-storage is used, but you can use any persistent storage system.
import AsyncStorage from '@react-native-async-storage/async-storage';
​
(async () => {
const sdk = client({
consumerKey: '',
consumerSecret: '',
});
​
const tokenData = await sdk.authenticate({
email: '',
password: '',
});
​
AsyncStorage.setItem('tokenData', JSON.stringify(tokenData));
})();
Afterwards you can use the stored tokenData to authenticate.
import AsyncStorage from '@react-native-async-storage/async-storage';
(async () => {
const tokenDataString = await AsyncStorage.getItem('tokenData');
const tokenData = JSON.parse(tokenDataString);
​
await sdk.authenticate({
token: tokenData.key,
tokenSecret: tokenData.secret,
});
})();
​