我无法登录到适用于 iOS 的 Hybris 移动应用 SDK。我在 iOS SDK 中使用 Hybris 提供的默认 B2B 示例应用程序。
我已经在我的机器上设置了 Hybris 平台,并将 IP 地址、端口和用户名设置到 Environments.plist 文件中。B2B 的默认用户名是 mark.rivers@pronto-hw.com 和密码:12341234
以下是错误:
2016-09-07 18:19:45:445 yB2BApp[20152:70b] 按下登录按钮 ...
2016-09-07 18:19:47.197 yB2BApp[20152:291779] 为用户 mark.rivers@pronto-hw.com 检索第一次令牌
2016-09-07 18:19:47:198 yB2BApp[20152:70b] injectionAuthorizationHeader Basic bWFyay5yaXZlcnNAcHJvbnRvLWh3LmNvbToxMjM0MTIzNA==
2016-09-07 18:19:47:198 yB2BApp[20152:70b] url https://:9002/authorizationserver/oauth/token 2016-09-07 18:19:47:198 yB2BApp[20152:70b] 参数
{
"client_id" = "mobile_android";
"client_secret" = secret;
"grant_type" = password;
password = 12341234;
username = "mark.rivers@pronto-hw.com";
}
2016-09-07 18:19:47:317 yB2BApp [20152:70b] 检索令牌期间出错:错误域 = com.alamofire.error.serialization.response 代码 = -1011“请求失败:未经授权 (401)”用户信息=0x7b86e6e0
{com.alamofire.serialization.response.error.response= { URL: https://:9002/authorizationserver/oauth/token } { 状态码: 401, headers {
"Content-Type" = "application/json;charset=UTF-8";
Date = "Wed, 07 Sep 2016 12:49:47 GMT";
Server = "Apache-Coyote/1.1";
"Transfer-Encoding" = Identity;
"X-Frame-Options" = SAMEORIGIN;
} }, NSErrorFailingURLKey=https://:9002/authorizationserver/oauth/token, NSLocalizedDescription=Request failed: unauthorized (401), com.alamofire.serialization.response.error.data=<7b0d0a20 20202265 72726f72 7322203a 205b207b 0d0a2020 20202020 226d6573 73616765 22203a20 22556e6b 6e6f776e 20636c69 656e7420 6d6f6269 6c655f61 6e64726f 6964222c 0d0a2020 20202020 22747970 6522203a 2022556e 61757468 6f72697a 65644572 726f7222 0d0a2020 207d205d 0d0a7d>}
2016-09-07 18:19:47:318 yB2BApp[20152:70b] 授权令牌检索期间的问题,原因:请求失败:未授权 (401)
2016-09-07 18:19:47:630 yB2BApp [20152:70b] 检索到错误...
在代码中还有一种方法 applyBasicAuth ,它添加了 authorizationHeader 并且 BASIC_AUTH 是恒定的,而不是基于密码。这是否应该改变:
- (void)applyBasicAuth {
if(self.restEngine) {
NSString *authorizationHeader = [NSString stringWithFormat:@"Basic %@", BASIC_AUTH];
[self.restEngine injectAuthorizationHeader:authorizationHeader];
} else {
DDLogError(@"!!! RestEngine not set !!!");
}
}
BASIC_AUTH 是:
#define BASIC_AUTH @"bW9iaWxlX2FuZHJvaWQ6c2VjcmV0"
Environments.plist 截图:
错误截图:
邮递员结果:
Hybris 控制台日志:
错误 [hybrisHTTP20] [xx.xxx.xx.xxx] [ClientCredentialsTokenEndpointFilter] 尝试对用户进行身份验证时发生内部错误。org.springframework.security.authentication.InternalAuthenticationServiceException:org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:110)的未知客户端mobile_ios~[spring-security-core-3.2.5.RELEASE.jar: 3.2.5.RELEASE] at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:132) ~[spring-security-core-3.2.5.RELEASE.jar: at org.springframework.security。 authentication.ProviderManager.authenticate(ProviderManager.java:156) ~[spring-security-core-3.2.5.RELEASE.jar:3.2.5.RELEASE] at org.springframework.security。






