verso_connect 0.1.3
verso_connect: ^0.1.3 copied to clipboard
Verso Connect for Flutter: let users connect their ChatGPT account from inside your app.
verso_connect #
Let users connect their ChatGPT account from inside your Flutter app. The
provider's login opens in-app with the device's own keyboard, autofill and
sign-in buttons; the plugin captures the session and hands you a
connectionId. Your backend receives connection.created at the same time.
This package wraps the native SDKs (iOS, Android); the whole flow is described in the mobile apps guide.
Install #
dependencies:
verso_connect: ^0.1.3
iOS 15+, Android 7+ (API 24).
Use #
Your backend signs a connect link with signLink() from @versoai/core and
returns its url to the app. The app secret never ships in the app. Fetch
the link right before presenting: links live 15 minutes and are consumed on
first use.
import 'package:verso_connect/verso_connect.dart';
Future<void> connectChatGPT() async {
final link = await fetchConnectLinkFromYourBackend();
try {
final connection = await VersoConnect.present(Uri.parse(link));
// connected; your backend also received connection.created
} on VersoConnectException catch (e) {
if (e.isCancelled) return;
rethrow;
}
}
Errors #
VersoConnect.present throws a VersoConnectException whose code is one of:
| code | meaning |
|---|---|
invalid_link |
the link carries no token or is not a URL |
cancelled |
the user closed the screen |
rejected |
Verso refused the connection; status holds the HTTP status (used link, account connected by another user, …) |
timed_out |
the provider session was not ready in time |
network |
a request failed |
no_presenter |
no visible activity / view controller to present from |
unavailable |
the native side of the plugin is not registered (rebuild the app) |
Example app #
example/ is a one-button partner app. Copy lib/demo_config.example.dart
to lib/demo_config.dart with the address and demo key of your deployment of
sdks/examples/partner-backend, then flutter run.