Я пытаюсь реализовать функцию входа в Discord в своем приложении Flutter, но всякий раз, когда я нажимаю кнопку Discord для входа в систему, я продолжаю получать сообщение об ошибке «неверный OAuth2 redirect_uri».
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');
}
},
),
Я создаю небольшой html-файл, который размещается на хостинге Firebase, и отлично перенаправляет Discord. Помните, что я все еще изучаю Oauth2... Помогите!!
Я пытаюсь реализовать функцию входа в Discord в своем приложении Flutter, но всякий раз, когда я нажимаю кнопку Discord для входа в систему, я продолжаю получать сообщение об ошибке «неверный OAuth2 redirect_uri».
// 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'); } }, ), [/code] Я создаю небольшой html-файл, который размещается на хостинге Firebase, и отлично перенаправляет Discord. Помните, что я все еще изучаю Oauth2... Помогите!!