flutter_auth_services 0.0.1
flutter_auth_services: ^0.0.1 copied to clipboard
A Flutter package for handling multiple authentication services.
Flutter Auth Services #
flutter_auth_services is a package that provides a simple way to authenticate users in your Flutter app and get their basic data (family name, given name, email) with a straightforward API.
The goal of this package is to simplify a hot mess that is authentication with 3rd party services, so you can focus on building your app.
This package aims to support Continue with Apple and Continue with Google on all platforms, and provide a stub for custom OAuth2 providers as well.
Why? #
Some providers (i.e. Sign in with Google on Web) have a very nasty API that is difficult to work with. We wrap all that conditional logic and expose it as a simple, unified interface whenever possible. Additionally, some data is hidden from the user, and in general working with auth isn't a nice experience.
Contents (and progress) #
- iOS
- ✅ Apple
- Android
- ❌ Apple
- Web
- ❌ Apple
- macOS
- ❌ Apple
- Windows
- ❌ Apple
- Linux
- ❌ Apple
Prerequisites #
- Apple Developer Program membership ($100/yr). You can't implement "Sign in with Apple" functionality without that, I'm sorry.
- If you need additional information check the readme of
sign_in_with_appleandgoogle_sign_in.
iOS #
Continue with Apple #
- Add
Sign in with Applecapability to your app. - Regenerate Provisioning Profile.
Continue with Google #
-
Create a new OAuth 2.0 Client on Google Auth Platform with "Application type" set to "iOS".
-
Add the following snippet to your
ios/Runner/Info.plistfile:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- Replace this identifier with reversed Client ID -->
<string>com.googleusercontent.apps.000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
</array>
</dict>
</array>
- When using
AuthServiceremember to specify your Client ID as well, e.g.:
// Auth configuration declared somewhere in the code...
final auth = AuthService(
google: const GoogleConfiguration(
clientId: const GoogleClientId(
// (🚨) Don't forget about this!
iOS: '000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
),
)
);
/// Callback on "sign in" button.
auth.continueWithGoogle();
Android #
Continue with Apple #
// TODO: Add this section.
Continue with Google #
// TODO: Add this section.
Web #
Continue with Apple #
- Add the following snippet to
web/index.html:
<script
type="text/javascript"
src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"
></script>
Continue with Google #
- Create a new OAuth 2.0 Client on Google Auth Platform with "Application type" set to "Web application".
- Specify "Authorised JavaScript origins" (for development it will be
http://localhostAND a variant with a port, e.g.http://localhost:56872). - Add the following snippet to
web/index.html(remember to replace with your Client ID):
<meta
name="google-signin-client_id"
content="000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"
/>
macOS #
Continue with Apple #
- Add
Sign in with Applecapability to your app. - Regenerate Provisioning Profile.
Continue with Google #
// TODO: Add this section.
Windows #
Continue with Apple #
// TODO: Add this section.
Continue with Google #
// TODO: Add this section.
Linux #
Continue with Apple #
// TODO: Add this section.
Continue with Google #
// TODO: Add this section.
Additional information #
- This package requires at least Flutter 3.27.0 to work.
- If there are any issues feel free to go to GitHub Issues and report a bug.