Comments (16)
After logout
I/flutter (18750): NoSuchMethodError: The getter 'statusCode' was called on null.
I/flutter (18750): Receiver: null
I/flutter (18750): Tried calling: statusCode
from directus-dart.
I have error after token expired on this line:
final sdk = await Directus(config.API_URL).init();
/auth/refresh Error
and not load public data
My temporary solution: :)
Future<Directus> getSdk() async {
try {
return await Directus(config.API_URL).init();
} catch (e) {
//Delete all directus__ prefs
SharedPreferences preferences = await SharedPreferences.getInstance();
for (String key in preferences.getKeys()) {
if (key.startsWith('directus__')) {
preferences.remove(key);
}
}
return await Directus(config.API_URL).init();
}
}
from directus-dart.
It should be fixed in 0.5.2. Reopen if issue persist after upgrade.
from directus-dart.
Oh anything not work after logout :)
from directus-dart.
remove .init() and working
from directus-dart.
init()
is needed because it initializes the storage, and gets auth data, without it, auth won't work propely.
It's calling /auth/refresh
because there is a token that is expired, and it tries to fetch a new one. But it should unlock after getting new token, and finish logging out, so this is definitely a bug
from directus-dart.
my auth.dart
import 'package:directus/directus.dart';
import 'package:meyirim/core/config.dart' as config;
Future<void> logout() async {
if (await isLoggedIn()) {
final sdk = await Directus(config.API_URL).init();
await sdk.auth.logout();
}
}
Future<void> login(String email, String password) async {
final sdk = await Directus(config.API_URL).init();
await sdk.auth.login(email: email, password: password);
}
Future<DirectusResponse<DirectusUser>> register(data) async {
final sdk = await Directus(config.API_URL).init();
final createdUser = sdk.users.createOne(DirectusUser.fromJson(data));
return createdUser;
}
Future<bool> isLoggedIn() async {
final sdk = await Directus(config.API_URL).init();
bool result = sdk.auth.isLoggedIn;
return result;
}
Or how to best way to add global sdk? final sdk = await Directus(config.API_URL).init();
from directus-dart.
You pass variable like any other, trough constructor, with provider, bloc... if that's what you're asking.
Soon there will be singleton version, you can track progress in #12.
You should initialize sdk only once, then just use that variable:
final sdk = await Directus(url).init();
isLoggedIn() {
return sdk.auth.isLoggedIn;
}
logout() {
sdk.auth.logout();
}
getData() {
return sdk.items('data').readMany();
}
from directus-dart.
Maybe i'm on right way
lib/core/auth.dart:7:26: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
print(sdk.auth.tokens!.accessToken);
and my token is expired. How clean it ? :)
from directus-dart.
found directus/directus@ff399f9#diff-2e0966802490ef6b64754924c1f0da2807f05359551e77bf115ce40384d56e0f
from directus-dart.
This library is using null safety, so you have to have Dart version that has enabled nnbd.
It's possible that error from the API is because of the bug that you linked, what version of directus are you using?
from directus-dart.
I used directus version directus/directus:v9.0.0-rc.28 from docker
from directus-dart.
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter_svg: ^0.19.2+1
flutter_swiper: ^1.1.6
intl: ^0.17.0-nullsafety.2
cached_network_image: ^2.5.0
page_transition: ^2.0.1-nullsafety.0
youtube_player_flutter: ^7.0.0+7
shared_preferences: ^0.5.12+4
form_validator: ^0.1.7
mask_text_input_formatter: ^1.2.1
dio: ^3.0.10
directus:
git:
url: https://github.com/apstanisic/directus-dart.git
flutter:
sdk: flutter
dependency_overrides:
flutter_inappwebview: ^4.0.0+4
from directus-dart.
not working :(
got error invalid user credentials.
from directus-dart.
I check if add request to url auth/refresh without auth token got same error
from directus-dart.
Which method is not working? Can you provide a code snippet?
Invalid user credentials is an error returned from the server, so I am not sure if bug is in your code, main repo or in this library.
Does the same happen when you use Postman?
from directus-dart.
Related Issues (20)
- Feature Request: making this package offline persistent natively HOT 1
- while uploadFile(filePath) it gets uploaded but some parsing error HOT 3
- Improve `DirectusFile.downloadUrl` method HOT 2
- Auto detect content type and send the type as a MediaType object. HOT 1
- A fully functional todo example app would be great HOT 1
- Solution: createMany() throws an error "Problem with Directus". HOT 2
- `sdk.fields` doesn't work with new api HOT 2
- How to get custom user fields? HOT 2
- Expose transport like JS SDK HOT 2
- fix items -> updateMany HOT 2
- refresh token interceptor bug fix HOT 2
- Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' HOT 4
- Auth Refresh fails and soft locks users out of the system HOT 4
- Deep Filter for translations HOT 5
- Making AuthResponse public so as to use this: "directus.auth.storage.storeLoginData(data)" HOT 1
- How do you Sign up a new user from the SDK HOT 1
- Broken link in code documentation HOT 4
- Upgrade the packages to Dart 3.0 HOT 2
- Why there is a Flutter Dependency in Directus Dart Package for shared_preferences? HOT 4
- Create a Flutter Project in example of `directus` package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directus-dart.