AWS Web RTC 需要使用Cognito身份验证,使用户登录并获取令牌。如果在使用WebRTC时出现'Error: AWS Web RTC Verification with Cognito”,则需要检查以下事项:
以下是使用AWS JavaScript SDK实现Cognito身份验证并获取Web RTC令牌的示例代码:
AWS.config.region = 'us-west-2';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'YOUR_IDENTITY_POOL_ID',
});
AWS.config.credentials.get(function (err) {
if (err) {
console.error('Error retrieving credentials:', err);
return;
}
// 获取Web RTC令牌并进行操作
// ...
});