SocialFlow class
The client half of magic-starter-laravel's social login contract.
Two ways in. The browser flow (any provider): redirectUrl starts it at the backend, browse waits for the callback carrying a one-time code, and exchange trades that code plus the PKCE verifier for the outcome. signIn, connect and confirm compose it. The native token endpoint (Google and Apple SDKs): token posts the provider's ID token.
Every flow mints a new Pkce pair and a new link ticket; nothing is cached
or persisted, so a retry is always a fresh flow. Requests go through magic's
Http facade, so the auth interceptor attaches the bearer a connect or a
confirm needs.
The browser callback is read from social_auth.callback.ios (a custom
scheme URL, myapp://auth/social) and social_auth.callback.android (an
https App Link, https://example.com/auth/social); they must match the
backend's redirects.ios and redirects.android. The web flow lands on
the app's own auth.html and needs no callback key.
Constructors
- SocialFlow({SocialPlatform? platform, WebFlowSlot? slot})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- platform → SocialPlatform
-
The platform the backend picks its redirect target for.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
authenticate(
{required String url, required String callbackUrlScheme, required FlutterWebAuth2Options options}) → Future< String> - The browser call, separated so tests can stand in for the platform.
-
Runs one browser flow for
pkceand exchanges its code. -
browse(
Uri url, {bool ephemeral = false}) → Future< Uri> -
Opens
urlin the system browser and returns the callback URL it lands on, carrying either acodeor anerror. -
confirm(
String provider) → Future< SocialAuthResult> -
Re-authenticates with an already linked
providerfor a step-up proof. -
connect(
String provider, Map< String, String> ? proof) → Future<SocialAuthResult> -
Links
providerto the signed-in account. -
exchange(
String code, String verifier) → Future< SocialAuthResult> -
Trades a callback
codeand the flow'sverifierfor its outcome. -
linkTicket(
String provider, String challenge, Map< String, String> ? proof) → Future<String> -
Asks for a single-use link ticket bound to the caller,
providerandchallenge.proofis as in connect. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
redirectUrl(
String provider, SocialPlatform platform, String challenge, {String? ticket, bool confirm = false}) → Uri -
The backend URL that starts a browser flow for
provider. -
signIn(
String provider) → Future< SocialAuthResult> -
Signs in with
providerthrough the browser. -
token(
String provider, {required String idToken, Nonce? nonce, String? authorizationCode, SocialIntent intent = SocialIntent.signIn, Map< String, String> ? proof}) → Future<SocialAuthResult> -
Posts a native SDK's
idTokentoauth/social/{provider}/token. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited