You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Afterwards, you'll reach a point where end-users need to be authorized and authenticated. A convenience method is provided that will perform an authorization request and automatically exchange the authorization code. This can be done in a few different ways, one of which is to use the OpenID Connect Discovery
25
25
26
26
```dart
27
-
var result = await appAuth.authorizeAndExchangeCode(
27
+
final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode(
28
28
AuthorizationTokenRequest(
29
29
'<client_id>',
30
30
'<redirect_url>',
@@ -39,7 +39,7 @@ Here the `<client_id>` and `<redirect_url>` should be replaced by the values reg
39
39
Rather than using the full discovery URL, the issuer could be used instead so that the process retrieving the discovery document is skipped
40
40
41
41
```dart
42
-
var result = await appAuth.authorizeAndExchangeCode(
42
+
final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode(
43
43
AuthorizationTokenRequest(
44
44
'<client_id>',
45
45
'<redirect_url>',
@@ -52,7 +52,7 @@ var result = await appAuth.authorizeAndExchangeCode(
52
52
If you already know the authorization and token endpoints, which may be because discovery isn't supported, then these could be explicitly specified
53
53
54
54
```dart
55
-
var result = await appAuth.authorizeAndExchangeCode(
55
+
final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode(
56
56
AuthorizationTokenRequest(
57
57
'<client_id>',
58
58
'<redirect_url>',
@@ -67,7 +67,7 @@ Upon completing the request successfully, the method should return an object (th
67
67
If you would prefer to not have the automatic code exchange to happen then can call the `authorize` method instead of the `authorizeAndExchangeCode` method. This will return an instance of the `AuthorizationResponse` class that will contain the code verifier that AppAuth generated (as part of implementing PKCE) when issuing the authorization request, the authorization code and additional parameters should they exist. Both of the code verifier and authorization code would need to be stored so they can then be reused to exchange the code later on e.g.
68
68
69
69
```dart
70
-
var result = await appAuth.token(TokenRequest('<client_id>', '<redirect_url>',
70
+
final AuthorizationTokenResponse result = await appAuth.token(TokenRequest('<client_id>', '<redirect_url>',
71
71
authorizationCode: '<authorization_code>',
72
72
discoveryUrl: '<discovery_url>',
73
73
codeVerifier: '<code_verifier>',
@@ -79,7 +79,7 @@ var result = await appAuth.token(TokenRequest('<client_id>', '<redirect_url>',
79
79
Some providers may return a refresh token that could be used to refresh short-lived access tokens. A request to get a new access token before it expires could be made that would like similar to the following code
80
80
81
81
```dart
82
-
var result = await appAuth.token(TokenRequest('<client_id>', '<redirect_url>',
82
+
final AuthorizationTokenResponse result = await appAuth.token(TokenRequest('<client_id>', '<redirect_url>',
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
50
+
- always_require_non_null_named_parameters
51
+
- always_specify_types
52
+
- annotate_overrides
53
+
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
54
+
- avoid_as
55
+
- avoid_bool_literals_in_conditional_expressions
56
+
# - avoid_catches_without_on_clauses # we do this commonly
57
+
# - avoid_catching_errors # we do this commonly
58
+
- avoid_classes_with_only_static_members
59
+
# - avoid_double_and_int_checks # only useful when targeting JS runtime
60
+
- avoid_empty_else
61
+
- avoid_field_initializers_in_const_classes
62
+
- avoid_function_literals_in_foreach_calls
63
+
# - avoid_implementing_value_types # not yet tested
64
+
- avoid_init_to_null
65
+
# - avoid_js_rounded_ints # only useful when targeting JS runtime
66
+
- avoid_null_checks_in_equality_operators
67
+
# - avoid_positional_boolean_parameters # not yet tested
68
+
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
69
+
- avoid_relative_lib_imports
70
+
- avoid_renaming_method_parameters
71
+
- avoid_return_types_on_setters
72
+
# - avoid_returning_null # there are plenty of valid reasons to return null
73
+
# - avoid_returning_null_for_future # not yet tested
74
+
- avoid_returning_null_for_void
75
+
# - avoid_returning_this # there are plenty of valid reasons to return this
76
+
# - avoid_setters_without_getters # not yet tested
77
+
# - avoid_shadowing_type_parameters # not yet tested
78
+
# - avoid_single_cascade_in_expression_statements # not yet tested
79
+
- avoid_slow_async_io
80
+
- avoid_types_as_parameter_names
81
+
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
82
+
- avoid_unused_constructor_parameters
83
+
- avoid_void_async
84
+
- await_only_futures
85
+
- camel_case_types
86
+
- cancel_subscriptions
87
+
# - cascade_invocations # not yet tested
88
+
# - close_sinks # not reliable enough
89
+
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
90
+
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
91
+
- control_flow_in_finally
92
+
# - curly_braces_in_flow_control_structures # not yet tested
93
+
# - diagnostic_describe_all_properties # not yet tested
94
+
- directives_ordering
95
+
- empty_catches
96
+
- empty_constructor_bodies
97
+
- empty_statements
98
+
# - file_names # not yet tested
99
+
- flutter_style_todos
100
+
- hash_and_equals
101
+
- implementation_imports
102
+
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
103
+
- iterable_contains_unrelated_type
104
+
# - join_return_with_assignment # not yet tested
105
+
- library_names
106
+
- library_prefixes
107
+
# - lines_longer_than_80_chars # not yet tested
108
+
- list_remove_unrelated_type
109
+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
110
+
- no_adjacent_strings_in_list
111
+
- no_duplicate_case_values
112
+
- non_constant_identifier_names
113
+
# - null_closures # not yet tested
114
+
# - omit_local_variable_types # opposite of always_specify_types
115
+
# - one_member_abstracts # too many false positives
0 commit comments