- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在开发经过开发人员身份验证的项目。我正在尝试使用下面的代码获取凭据。但它给了我以下错误。
我已将 IdentityId 和 token 从服务器代码手动粘贴到此代码中:
Caused by: com.amazonaws.services.cognitoidentity.model.ResourceNotFoundException: Identity 'ap-northeast-1:fe81cd76-e9d4-4416-99ea-b684b78743c8' not found. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: 2ac65fe8-d41a-11e5-8674-677eefdb5331)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:709)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:385)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:533)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getCredentialsForIdentity(AmazonCognitoIdentityClient.java:406)
at com.example.sandesh.aws.MainActivity$network.doInBackground(MainActivity.java:101)
at com.example.sandesh.aws.MainActivity$network.doInBackground(MainActivity.java:52)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
这是我的代码:MainActivity.java
public class MainActivity extends AppCompatActivity {
Button button;
protected static CognitoCachingCredentialsProvider credentialsProvider = null;
private GetCredentialsForIdentityResult credentialsForIdentityResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
network net = new network();
net.execute();
}
});
}
public class network extends AsyncTask<Void,Void,String>{
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(Void... params) {
Authentication developerProvider = new Authentication(
null,
"ap-northeast-1:XXXXXXXXXXXXXXXXXX",
Regions.AP_NORTHEAST_1);
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
developerProvider,
Regions.AP_NORTHEAST_1);
HashMap<String, String> loginsMap = new HashMap<String, String>();
loginsMap.put(developerProvider.getProviderName(), "7386372772");
credentialsProvider.setLogins(loginsMap);
credentialsProvider.refresh();
GetCredentialsForIdentityRequest credentialsForIdentityRequest = new GetCredentialsForIdentityRequest();
credentialsForIdentityRequest.setIdentityId(developerProvider.getIdentityId());
credentialsForIdentityRequest.setLogins(loginsMap);
AmazonCognitoIdentityClient cognitoIdentityClient = new AmazonCognitoIdentityClient(credentialsProvider);
credentialsForIdentityResult = cognitoIdentityClient.getCredentialsForIdentity(credentialsForIdentityRequest);
Log.d("access_key",credentialsForIdentityResult.getCredentials().getAccessKeyId());
return credentialsForIdentityResult.getCredentials().getAccessKeyId();
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
}}
身份验证.java
public class Authentication extends AWSAbstractCognitoDeveloperIdentityProvider {
private static final String PROVIDERNAME = "login.blupinch.app";
public String response = " ";
String line = " ";
public Authentication(String accountId, String identityPoolId, Regions region) {
super(accountId, identityPoolId, region);
}
@Override
public String getProviderName() {
return PROVIDERNAME;
}
public String refresh() {
setToken(null);
if (getProviderName() != null &&
!this.loginsMap.isEmpty() &&
this.loginsMap.containsKey(getProviderName())) {
update(identityId, token);
return "eyJraWQiOiJhcC1ub3J0aGVhc3QtMTEiLCJ0eXAiOiJKV1MiLCJhbGciOiJSUzUxMiJ9.eyJzdWIiOiJhcC1ub3J0aGVhc3QtMTpmZTgxY2Q3Ni1lOWQ0LTQ0MTYtOTllYS1iNjg0Yjc4NzQzYzgiLCJhdWQiOiJhcC1ub3J0aGVhc3QtMTphODcxZmE1Zi0yM2EyLTQ4MGQtYmFhNi1iNGVkMzE0MzcyNDQilCJhbXIiOlsiYXV0aGVudGljYXRlZCIsImxvZ2luLmJsdXBpbmNoLmFwcCIsImxvZ2luLmJsdXBpbmNoLmFwcDphcC1ub3J0aGVhc3QtMTphODcxZmE1Zi0yM2EyLTQ4MGQtYmFhNi1iNGVkMzE0MzcyNDQ6NzM4NjM3Mjg3MiJdLCJpc3MiOiJodHRwczovL2NvZ25pdG8taWRlbnRpdHkuYW1hem9uYXdzLmNvbSIsImV4cCI6MTQ1NTU5NTM5NywiaWF0IjoxNDU1NTU5Mzk3fQ.fHHH6aeCn5EaJGxGD6tw7bWyQpPHuYcW8SZLRGVn-3cbamJrWEPmUnNvcLJ-D6nL8AvMQy7-s1LGQ5MNaiuIH7QF6W8aWt2OMALmA_Y7eqpGQ6iQXVma_jTZSpiyBe2cPNggWgeslPtFxomwE90vW0rzS1sY3D5Y3UbnrIHNdiPKIzzP9JaQo1IsTJMKEpQM-jzWP6stV1radDuIzWQroBVQseOQSD-MXV_-cgWWSx0eQmtFbjJW6RP_nACgh0uTbGmMuOi2iKXKQAdGlYWO-PHlShbiHT-WLQoZNWuh95Hh9dMldv-mNdnYSblqYyqptLA3kObioI08XXkTqwaaAw";
} else {
this.getIdentityId();
return null;
}
}
public String getIdentityId() {
identityId = "ap-northeast-1:XXXXXXXXXXXXXXXXXXXXXXXX";
if (identityId == null) {
if (getProviderName() != null && !this.loginsMap.isEmpty()
&& this.loginsMap.containsKey(getProviderName())) {
update(identityId, token);
return "ap-northeast-1:XXXXXXXXXXXXXXXXXXXX";
} else {
return super.getIdentityId();
}
} else {
return identityId;
}
}}
我在 PHP 中尝试过,我执行了 getOpenIdTokenForDeveloperIdentity 、 stsClient 和 AssumerolewithWebIdentity 来获取凭据,效果很好。先感谢您。
最佳答案
使用开发者验证身份时,调用 GetCredentialsForIdentity 的登录映射应将“cognito-identity.amazonaws.com”作为 key ,而不是开发人员提供商名称。
此外,您不应该自己调用此方法,SDK 会处理这个问题。
更新:
调用 getCredentialsForIdentity 时,在登录映射中,当键为“cognito-identity.amazonaws.com”时,该值应为您在调用 GetOpenIdTokenForDeveloperIdentity 后从后端获取的 token 。您不需要获取执行 AWS 操作的凭证,只需使用此凭证提供程序初始化 AWS 服务客户端即可开始操作。
关于java - 亚马逊认知 : identity not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35417794/
使用 Cognito 的 forgotPassword 函数时,如果我尝试运行忘记密码方法超过 5 次,我会收到“LimitExceededException”错误。 此时是否有关于此的进一步文档?
我正在尝试向 Azure 的认知文本分析提供一些简单的、Hello-Worldish 的 JSON 示例;使用此测试数据: { "documents": [ { "lan
我正在尝试向 Azure 的认知文本分析提供一些简单的、Hello-Worldish 的 JSON 示例;使用此测试数据: { "documents": [ { "lan
我无法获得我的 CognitoIdentity 的凭据。当用户通过身份验证成功后,他需要获得一个身份才能访问其他 AWS 服务。在我的例子中就是 AWS IoT。但不知何故,我无法获得任何凭证。 这是
我正在使用 aws lambdas、dynamodb 和 cognito 构建身份验证系统。 我一直在比较 getOpenIdTokenForDeveloperIdentity() 提供的 token
我在 Cognito 中单击了“重置密码”,现在登录时出现“PasswordResetRequiredException”,我该如何处理?我在文档中找不到任何内容告诉我应该怎么做? 最佳答案 检查这个
我正在使用 Azure 认知服务,更准确地说是“bing 图像搜索服务”。我发送请求以获取与特定关键字相关的图像。 为此,我向正确的 Azure 端点发出 HTTP REST 请求: 'https:/
我正在使用 Azure 认知服务,更准确地说是“bing 图像搜索服务”。我发送请求以获取与特定关键字相关的图像。 为此,我向正确的 Azure 端点发出 HTTP REST 请求: 'https:/
如果用户登录,我会检查用户是否有 IoT 所需的策略,如果没有,我会附加它。 如果我是第一次登录,这很好用。 现在,当我注销并尝试使用不同的用户登录时,由于某种原因缺少凭据,当我刷新页面时,它再次工作
我将使用 Express 制作的 API 与 API Gateway 封装在一起。我正在使用 Cognito Userpool 来验证 API Gateway。 当我使用 Angular2 http
目前,每次重新启动应用程序时,用户都必须登录。我希望应用程序能够记住用户,直到他们手动注销。以下是我认为可行的方法,但它只是完全绕过了登录 Activity 。 @Override protected
想知道,如何识别图像是否包含特定对象并且该对象完全可见(而不是部分可见)。 Cognitive Services Computer Vision API提供了一组标签和我发送的图像的描述,但是,没有信
用例如下 我们的系统中有面孔列表 用户将上传一张图片 我们希望显示与上传图像匹配的面孔列表,例如置信度 >0.8 现在查看how to ,我的理解如下 使用人脸检测API,我们需要首先上传所有图像,包
用例如下 我们的系统中有面孔列表 用户将上传一张图片 我们希望显示与上传图像匹配的面孔列表,例如置信度 >0.8 现在查看how to ,我的理解如下 使用人脸检测API,我们需要首先上传所有图像,包
上下文 我使用 booth Cognito 用户池和 Cognito 身份池来登录用户。 我想完成一个简单的任务,让用户在 iOS 应用程序(Swift 应用程序)上登录。 我的应用程序基于自定义版本
我在捕获 Cognito 注册错误时遇到困难。当 Cognito 返回“UsernameExistsException”、“message”:“User already exists”错误时,我试图提
我正在试验 Cognito,当我认为它开始没问题时,我遇到了 (Google) token 在 1 小时后过期的问题。 当我开始使用干净的设备时,我可以注册并使用该应用程序 1 小时,然后当我需要刷新
我正在使用 AWS Cognito ( http://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-us
是否有办法防止云形成更新删除或重新创建 Cognito 用户池资源?我想消除这种情况发生的可能性。有办法吗? 最佳答案 我找到了答案。使用删除策略。适用于任何 Cloud Formation 资源:
我正在调用 Azure 认知 API 进行 OCR 文本识别,并且同时传递 10 个图像(因为下面的代码一次只接受一个图像 - 即 10 个独立的请求并行),从处理的角度来看,这对我来说效率不高,因为
我是一名优秀的程序员,十分优秀!