I want to get message from other' channel with oauth2 (I'm a member of that guild).
Oauth2 scope: "messages.read"
Future<ResponseApi> getChannelMessages({required String channelId, String? lastMessageId}) async {
final uri = Uri.https(
'discord.com',
'/api/channels/$channelId/messages',
// {if (lastMessageId != null) 'after': lastMessageId},
);
return await http.get(
uri,
headers: {
// 'Authorization': 'Bot $discordBotToken',
'Authorization': 'Bearer ${authDiscord.accessToken}',
},
).then((res) {
if (res.statusCode == 200) {
return ResponseApi(success: true, response: res);
} else {
throw (res);
}
}).catchError((error, stackTrace) => ResponseApi(success: false, response: error));
}
Response: "message": "401: Unauthorized"
I tried with bot token, but it only work with channel bot is member, otherwise:
return 403: "message": "Missing Access", "code": 50001
What did I do wrong?