device code response class
This commit is contained in:
parent
867a899d2f
commit
90141e6286
2 changed files with 51 additions and 3 deletions
|
@ -23,3 +23,51 @@ class AuthorizationTokenResponse {
|
|||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the response for an OAuth2 `device_code` request.
|
||||
class DeviceCodeResponse {
|
||||
/// REQUIRED. The device verification code.
|
||||
final String deviceCode;
|
||||
|
||||
/// REQUIRED. The end-user verification code.
|
||||
final String userCode;
|
||||
|
||||
/// REQUIRED. The end-user verification URI on the authorization
|
||||
/// server. The URI should be short and easy to remember as end users
|
||||
/// will be asked to manually type it into their user-agent.
|
||||
final Uri verificationUri;
|
||||
|
||||
/// OPTIONAL. A verification URI that includes the [userCode] (or
|
||||
/// other information with the same function as the [userCode]),
|
||||
/// designed for non-textual transmission.
|
||||
final Uri verificationUriComplete;
|
||||
|
||||
/// OPTIONAL. The minimum amount of time in seconds that the client
|
||||
/// SHOULD wait between polling requests to the token endpoint. If no
|
||||
/// value is provided, clients MUST use 5 as the default.
|
||||
final int interval;
|
||||
|
||||
/// The lifetime, in *seconds* of the [deviceCode] and [userCode].
|
||||
final int expiresIn;
|
||||
|
||||
const DeviceCodeResponse(
|
||||
this.deviceCode, this.userCode, this.verificationUri, this.expiresIn,
|
||||
{this.verificationUriComplete, this.interval});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
var out = <String, dynamic>{
|
||||
'device_code': deviceCode,
|
||||
'user_code': userCode,
|
||||
'verification_uri': verificationUri.toString(),
|
||||
};
|
||||
|
||||
if (verificationUriComplete != null) {
|
||||
out['verification_uri_complete'] = verificationUriComplete.toString();
|
||||
}
|
||||
|
||||
if (interval != null) out['interval'] = interval;
|
||||
if (expiresIn != null) out['expires_in'] = expiresIn;
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'response.dart';
|
|||
import 'token_type.dart';
|
||||
|
||||
/// A request handler that performs an arbitrary authorization token grant.
|
||||
typedef Future<AuthorizationTokenResponse> ExtensionGrant(
|
||||
typedef FutureOr<AuthorizationTokenResponse> ExtensionGrant(
|
||||
RequestContext req, ResponseContext res);
|
||||
|
||||
Future<String> _getParam(RequestContext req, String name, String state,
|
||||
|
@ -62,12 +62,12 @@ abstract class AuthorizationServer<Client, User> {
|
|||
FutureOr<Client> findClient(String clientId);
|
||||
|
||||
/// Verify that a [client] is the one identified by the [clientSecret].
|
||||
Future<bool> verifyClient(Client client, String clientSecret);
|
||||
FutureOr<bool> verifyClient(Client client, String clientSecret);
|
||||
|
||||
/// Prompt the currently logged-in user to grant or deny access to the [client].
|
||||
///
|
||||
/// In many applications, this will entail showing a dialog to the user in question.
|
||||
requestAuthorizationCode(
|
||||
FutureOr requestAuthorizationCode(
|
||||
Client client,
|
||||
String redirectUri,
|
||||
Iterable<String> scopes,
|
||||
|
|
Loading…
Reference in a new issue