Comments (6)
I've just tested it locally with the Dart cli and I'm not able to reproduce it (PocketBase Dart SDK v0.14.1 and PocketBase executable v0.17.7).
// example.dart
import "dart:io";
import "package:pocketbase/pocketbase.dart";
void main() {
final pb = PocketBase("http://127.0.0.1:8090");
pb.collection("users").authWithOAuth2("discord", (url) async {
// replace with "explorer" for windows or "open" for mac
Process.run("xdg-open", [url.toString()]);
}).then((result) {
print("Result: $result");
}).catchError((dynamic err) {
print("Error: $err");
});
}
Run with dart run example.dart
(tested on Linux, for other platforms change the command).
The above is running a shell command to fire a browser window from the terminal but it should be the same with url_launcher
or any other package (the goal is to open the signin url from the callback in a browser window).
I suspect in your case you are testing in Flutter web, where as mentioned earlier, streamed responses are not supported out of the box and you have to provide your own http client as shown in https://github.com/pocketbase/dart-sdk#limitations.
If that's not the case, please provide more details on what platform your code is running and the versions of the PocketBase executable and SDK, and I'll investigate it further.
from dart-sdk.
Where is the Dart code running, aka. what platform do you target?
If it is Flutter Web, the realtime events are not supported there (the "all-in-one" authWithOAuth2()
call relies on a realtime subscription) and you have to provide a custom http client (see https://github.com/pocketbase/dart-sdk#limitations).
from dart-sdk.
Side-note: If you use Fly, also keep in mind that the last time I checked their free service had 60s limit for how long a connection can remain open, which is not an issue with the regular realtime subscriptions as there is autoreconnect, but with the "all-in-one" OAuth2 call that means that the OAuth2 sign process must happen under 60s, otherwise you'll get an error for "missing/invalid client id" or similar.
from dart-sdk.
Thanks for the hint. Indeed I am using flutter. This issue was resolved by httpClientFactory: kIsWeb ? () => FetchClient(mode: RequestMode.cors) : null,
However the callback gives me an error:
{"code":404,"message":"Missing or invalid OAuth2 subscription client.","data":{}}
So basically oauth doesnt work on flutter web with pocketbase dart sdk?
Thats my code:
final pb = PocketBase('https://someurl.fly.dev', httpClientFactory: kIsWeb ? () => FetchClient(mode: RequestMode.cors) : null,);
print("GO");
final authData2 =
await pb.collection('users').authWithOAuth2('discord', (url) async {
print(url);
await launchUrl(url);
});
from dart-sdk.
See the note in #47 (comment). It could be also an issue with the fetch_client
compatibility as I haven't tested it thoroughly.
If you are using Flutter Web just for dev preview/tests, I'd recommend using Flutter Desktop instead.
from dart-sdk.
Issue was resolved. Provider redirect uri was incorrect.
Works for Flutter WEB:
final pb = PocketBase(
'https://url.fly.dev',
httpClientFactory: () => FetchClient(mode: RequestMode.cors),
);
final authData = await pb
.collection('users')
.authWithOAuth2('discord', (url) async {
await launchUrl(url);
});
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
```
from dart-sdk.
Related Issues (20)
- android app auth data HOT 2
- Issue with filtering in dart-sdk HOT 1
- Dart suggestion code should not contain quotes HOT 1
- Bug: authStore did not save token and model. HOT 1
- Can't create new user with OAuth (404 from PB) HOT 2
- How to close browser with successful oauth using authWithOAuth2? HOT 7
- how to yield from subscription function HOT 4
- Upgrade http to 1.0.0 HOT 3
- Flutter pocketbase db 501 error HOT 17
- Need info HOT 1
- Add a RecordModel.getMapValue() method HOT 3
- can't reach the server from flutter when running in real android device HOT 1
- Streamline requests' _jsonRequest and _multipartRequest body HOT 1
- Username/Password authentication from Flutter Web HOT 10
- How to filter the expanded items only HOT 2
- I cant add pocketbase dependency in my flutter project. How to fix? HOT 1
- Weird create function with body and files in Dart SDK HOT 2
- make models `RecordModel|AdminModel|null` use a base type `BaseModel` to avoid use of `dynamic` HOT 1
- missed argument collection name inside buildUrl() HOT 5
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 dart-sdk.