Skip to main content

piano_id_facebook 1.0.8 copy "piano_id_facebook: ^1.0.8" to clipboard
piano_id_facebook: ^1.0.8 copied to clipboard

Piano ID Flutter SDK (Facebook).

Piano ID SDK (Facebook) for Flutter #

Facebook sign-in for piano_id: PianoIDFacebookOAuthProvider is the PianoIDOAuthProvider behind the Facebook button on the Piano ID sign-in screen.

Installation #

Add the dependency to your pubspec.yaml:

dependencies:
  piano_id: ^1.0.8
  piano_id_facebook: ^1.0.8

The provider signs in through flutter_facebook_auth, so your application still needs that package's platform setup — and it has to be set up for the same Facebook app Piano ID is configured with, since that is the app the access token is issued for and the one Piano ID verifies it against:

  • Android — facebook_app_id, facebook_client_token and fb_login_protocol_scheme in res/values/strings.xml, plus the Facebook activities and provider in AndroidManifest.xml.
  • iOS — FacebookAppID, FacebookClientToken and FacebookDisplayName in Info.plist, plus the fb<APP_ID> URL scheme.

See the flutter_facebook_auth setup guide for the details.

Usage #

List the provider in the Piano ID configuration:

import 'package:piano_common/piano_common.dart';
import 'package:piano_id/piano_id.dart';
import 'package:piano_id_facebook/piano_id_facebook.dart';

final piano = await Piano.init(
  endpoint: PianoEndpoint.production,
  aid: '<AID>',
  configurations: [
    PianoIDConfiguration(providers: [PianoIDFacebookOAuthProvider()]),
  ],
);

// The sign-in screen now shows a Facebook button; picking it signs the user in
// with Facebook and finishes the Piano ID sign-in with the resulting token.
final token = await piano.id().signIn(context: context);

Nothing else is needed: the Facebook app id comes from the platform setup, and Piano ID supplies the app it expects the token to come from. A user who dismisses the Facebook UI leaves the sign-in screen open, so another way to sign in can be picked.

Configuration #

PianoIDFacebookOAuthProvider(
  // The permissions the login asks for. `email` is what Piano ID builds the
  // user from.
  permissions: ['email', 'public_profile', 'user_birthday'],
  // Which Facebook UI the login is shown in, on Android. Unused on iOS.
  loginBehavior: LoginBehavior.nativeWithFallback,
)

LoginBehavior is exported by this package, so configuring it needs no direct dependency on flutter_facebook_auth.

The login always runs with LoginTracking.enabled, which is not configurable: Piano ID checks the token against the Graph API, so it has to be a classic access token. Facebook's limited login returns an OpenID token about the user instead, which Piano ID has no way to verify.

A sign-in whose token turns out to belong to another Facebook app than the one Piano ID is configured with fails with both app ids in the message, rather than being refused by Piano ID with a less obvious error.

0
likes
140
points
453
downloads

Documentation

API reference

Publisher

verified publisherpiano.io

Weekly Downloads

Piano ID Flutter SDK (Facebook).

Homepage

License

Apache-2.0 (license)

Dependencies

flutter, flutter_facebook_auth, piano_common, piano_id

More

Packages that depend on piano_id_facebook