Line data Source code
1 : import 'package:freezed_annotation/freezed_annotation.dart';
2 :
3 : import '../../types/typedefs.dart';
4 :
5 : part 'apple_id_credential.freezed.dart';
6 : part 'apple_id_credential.g.dart';
7 :
8 : /// A freezed version of [sign_in_with_apple/authorization_credential.dart]
9 : ///
10 : /// Authorization details from a successful Sign in with Apple flow.
11 : ///
12 : /// Most fields are optional in this class.
13 : ///
14 : /// Especially [givenName], [familyName], and [email] member will only be provided on the first authorization between
15 : /// the app and Apple ID.
16 : ///
17 : /// The [authorizationCode] member is always present and should be used to check the authorizations with Apple servers
18 : /// from your backend. Upon successful validation, you should create a session in your system for the current user,
19 : /// or consider her now logged in.
20 : @freezed
21 : class AppleIdCredential with _$AppleIdCredential {
22 : factory AppleIdCredential({
23 : /// An identifier associated with the authenticated user.
24 : ///
25 : /// This will always be provided on iOS and macOS systems. On Android, however, this will not be present.
26 : /// This will stay the same between sign ins, until the user deauthorizes your App.
27 : String? userIdentifier,
28 :
29 : /// The users given name, in case it was requested.
30 : /// You will need to provide the [AppleIDAuthorizationScopes.fullName] scope to the [AppleIDAuthorizationRequest] for requesting this information.
31 : ///
32 : /// This information will only be provided on the first authorizations.
33 : /// Upon further authorizations, you will only the [userIdentifier],
34 : /// meaning you will need to store this data securely on your servers.
35 : /// For more information see: https://forums.developer.apple.com/thread/121496
36 : String? givenName,
37 :
38 : /// The users family name, in case it was requested.
39 : /// You will need to provide the [AppleIDAuthorizationScopes.fullName] scope to the [AppleIDAuthorizationRequest] for requesting this information.
40 : ///
41 : /// This information will only be provided on the first authorizations.
42 : /// Upon further authorizations, you will only get the [userIdentifier],
43 : /// meaning you will need to store this data securely on your servers.
44 : /// For more information see: https://forums.developer.apple.com/thread/121496
45 : String? familyName,
46 :
47 : /// The users email in case it was requested.
48 : /// You will need to provide the [AppleIDAuthorizationScopes.email] scope to the [AppleIDAuthorizationRequest] for requesting this information.
49 : ///
50 : /// This information will only be provided on the first authorizations.
51 : /// Upon further authorizations, you will only get the [userIdentifier],
52 : /// meaning you will need to store this data securely on your servers.
53 : /// For more information see: https://forums.developer.apple.com/thread/121496
54 : String? email,
55 :
56 : /// The verification code for the current authorization.
57 : ///
58 : /// This code should be used by your server component to validate the authorization with Apple within 5 minutes upon receiving it.
59 : required String authorizationCode,
60 :
61 : /// A JSON Web Token (JWT) that securely communicates information about the user to your app.
62 : String? identityToken,
63 :
64 : /// The `state` parameter that was passed to the request.
65 : ///
66 : /// This data is not modified by Apple.
67 : String? state,
68 : }) = _AppleIdCredential;
69 :
70 0 : factory AppleIdCredential.fromJson(JsonMap json) =>
71 0 : _$AppleIdCredentialFromJson(json);
72 : }
|