Код: Выделить всё
Код: Выделить всё
LoginProvider(
icon: FontAwesomeIcons.discord,
callback: () async {
try {
debugPrint('Start Discord sign in');
// Initialize the AppAuth and authorization token request
final FlutterAppAuth appAuth = FlutterAppAuth();
final AuthorizationTokenResponse? result =
await appAuth.authorizeAndExchangeCode(
AuthorizationTokenRequest(
'1288183304121483326', // Replace with your Discord client ID
'https://oasis-gameapp.web.app', // Replace with your redirect URI
serviceConfiguration:
const AuthorizationServiceConfiguration(
authorizationEndpoint:'https://discord.com/api/oauth2/authorize', // Discord auth URL
tokenEndpoint:'https://discord.com/api/oauth2/token', // Discord token URL
),
scopes: [
'identify',
'email'
], // Add other scopes as needed
),
);
// Check if the result is not null, meaning login was successful
if (result != null) {
debugPrint('Discord sign in successful');
debugPrint('Access Token: ${result.accessToken}');
debugPrint('ID Token: ${result.idToken}');
debugPrint('Refresh Token: ${result.refreshToken}');
return result
.accessToken; // Return the access token or handle login success
} else {
debugPrint('Discord sign in canceled or failed');
return null;
}
} catch (e) {
debugPrint('Error during Discord sign in: $e');
return null;
} finally {
debugPrint('Stop Discord sign in');
}
},
),
Подробнее здесь: https://stackoverflow.com/questions/790 ... er-project