mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 19:39:25 +08:00
fix: improve oauth2 field
This commit is contained in:
@@ -55,11 +55,11 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
_usernameController = TextEditingController(text: oauth2?.username ?? '');
|
_usernameController = TextEditingController(text: oauth2?.username ?? '');
|
||||||
_passwordController = TextEditingController(text: oauth2?.password ?? '');
|
_passwordController = TextEditingController(text: oauth2?.password ?? '');
|
||||||
_refreshTokenController =
|
_refreshTokenController =
|
||||||
TextEditingController(text: oauth2?.refreshToken ?? 'N/A');
|
TextEditingController(text: oauth2?.refreshToken ?? '');
|
||||||
_identityTokenController =
|
_identityTokenController =
|
||||||
TextEditingController(text: oauth2?.identityToken ?? 'N/A');
|
TextEditingController(text: oauth2?.identityToken ?? '');
|
||||||
_accessTokenController =
|
_accessTokenController =
|
||||||
TextEditingController(text: oauth2?.accessToken ?? 'N/A');
|
TextEditingController(text: oauth2?.accessToken ?? '');
|
||||||
_codeChallengeMethod = oauth2?.codeChallengeMethod ?? 'sha-256';
|
_codeChallengeMethod = oauth2?.codeChallengeMethod ?? 'sha-256';
|
||||||
|
|
||||||
// Load credentials from file if available
|
// Load credentials from file if available
|
||||||
@@ -79,8 +79,8 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
} else {
|
} else {
|
||||||
_refreshTokenController.text = "N/A";
|
_refreshTokenController.text = "N/A";
|
||||||
}
|
}
|
||||||
if (decoded['id_token'] != null) {
|
if (decoded['idToken'] != null) {
|
||||||
_identityTokenController.text = decoded['identityToken']!;
|
_identityTokenController.text = decoded['idToken']!;
|
||||||
} else {
|
} else {
|
||||||
_identityTokenController.text = "N/A";
|
_identityTokenController.text = "N/A";
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,7 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
} else {
|
} else {
|
||||||
_accessTokenController.text = "N/A";
|
_accessTokenController.text = "N/A";
|
||||||
}
|
}
|
||||||
|
// "expiration": 1753258479104
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,7 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: ClampingScrollPhysics(),
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Grant Type",
|
"Grant Type",
|
||||||
@@ -243,7 +244,6 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
readOnly: widget.readOnly,
|
readOnly: widget.readOnly,
|
||||||
controller: _refreshTokenController,
|
controller: _refreshTokenController,
|
||||||
hintText: "Refresh Token",
|
hintText: "Refresh Token",
|
||||||
isObscureText: true,
|
|
||||||
onChanged: (_) => _updateOAuth2(),
|
onChanged: (_) => _updateOAuth2(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -252,7 +252,6 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
readOnly: widget.readOnly,
|
readOnly: widget.readOnly,
|
||||||
controller: _identityTokenController,
|
controller: _identityTokenController,
|
||||||
hintText: "Identity Token",
|
hintText: "Identity Token",
|
||||||
isObscureText: true,
|
|
||||||
onChanged: (_) => _updateOAuth2(),
|
onChanged: (_) => _updateOAuth2(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -260,7 +259,6 @@ class _OAuth2FieldsState extends State<OAuth2Fields> {
|
|||||||
AuthTextField(
|
AuthTextField(
|
||||||
readOnly: widget.readOnly,
|
readOnly: widget.readOnly,
|
||||||
controller: _accessTokenController,
|
controller: _accessTokenController,
|
||||||
isObscureText: true,
|
|
||||||
hintText: "Access Token",
|
hintText: "Access Token",
|
||||||
onChanged: (_) => _updateOAuth2(),
|
onChanged: (_) => _updateOAuth2(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -197,7 +197,9 @@ Future<HttpRequestModel> handleAuth(
|
|||||||
secret: oauth2.clientSecret,
|
secret: oauth2.clientSecret,
|
||||||
authorizationEndpoint: Uri.parse(oauth2.authorizationUrl),
|
authorizationEndpoint: Uri.parse(oauth2.authorizationUrl),
|
||||||
redirectUrl: Uri.parse(
|
redirectUrl: Uri.parse(
|
||||||
oauth2.redirectUrl ?? "apidash://oauth2/callback",
|
oauth2.redirectUrl!.isEmpty
|
||||||
|
? "apidash://oauth2/callback"
|
||||||
|
: oauth2.redirectUrl!,
|
||||||
),
|
),
|
||||||
tokenEndpoint: Uri.parse(oauth2.accessTokenUrl),
|
tokenEndpoint: Uri.parse(oauth2.accessTokenUrl),
|
||||||
credentialsFile: credentialsFile,
|
credentialsFile: credentialsFile,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ Future<oauth2.Client> oAuth2AuthorizationCodeGrantHandler({
|
|||||||
log('OAuth2 authorization successful, saving credentials');
|
log('OAuth2 authorization successful, saving credentials');
|
||||||
|
|
||||||
await credentialsFile.writeAsString(client.credentials.toJson());
|
await credentialsFile.writeAsString(client.credentials.toJson());
|
||||||
|
log(client.credentials.toJson());
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user