mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 01:15:03 +03:00
104 lines
2.6 KiB
Plaintext
104 lines
2.6 KiB
Plaintext
---
|
|
id: auth-signin
|
|
title: 'auth.signIn()'
|
|
slug: auth-signin
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/dart.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabsPanel from '@theme/TabsPanel'
|
|
|
|
Log in an existing user, or login via a third-party provider.
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.signIn(email: 'example@email.com', password: 'example-password');
|
|
|
|
final user = res.data?.user;
|
|
final error = res.error;
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
## Notes
|
|
|
|
- A user can sign up via email, phone number.
|
|
- If you provide `email` without a `password`, the user will be sent a magic link.
|
|
- The magic link's destination URL is determined by the SITE_URL config variable. To change this, you can go to Authentication -> Settings on [app.supabase.com](https://app.supabase.com)
|
|
- Similarly, if you provide `phone` without a `password`, the user will be sent a one time password.
|
|
- If you are looking to sign users in with OAuth in Flutter apps, go to [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider).
|
|
|
|
## Examples
|
|
|
|
### Sign in with email.
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.signIn(email: 'example@email.com', password: 'example-password');
|
|
|
|
final user = res.data?.user;
|
|
final error = res.error;
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Sign in with magic link.
|
|
|
|
If email is provided, but no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.signIn(email: 'example@email.com');
|
|
|
|
final error = res.error;
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Get OAuth sign in URL.
|
|
|
|
Passing provider parameter to `signIn()` will return a URL to sign your user in via OAuth.
|
|
If you are looking to sign in a user via OAuth on Flutter app, go to [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider).
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.signIn(provider: Provider.github);
|
|
|
|
final url = res.data?.url;
|
|
final error = res.error;
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|