我正密切关注this document以从我的iOS应用程序授权硬件:
在iOS部分,在步骤5):
- (IBAction)onLogInButtonClicked:(id)sender {
NSArray *requestScopes = [NSArray arrayWithObjects:@"alexa:all", nil];
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
NSString* scopeData = [NSString stringWithFormat:@"{\"alexa:all\":{\"productID\":\"%@\","
"\"productInstanceAttributes\":{\"deviceSerialNumber\":\"%@\"}}}",
productId, deviceSerialNumber];
options[kAIOptionScopeData] = scopeData;
options[kAIOptionReturnAuthCode] = @YES;
options[kAIOptionCodeChallenge] = @"CODE_CHALLENGE_GOES_HERE";
options[kAIOptionCodeChallengeMethod] = @"S256";
[AIMobileLib authorizeUserForScopes:requestScopes delegate:delegate options:options];
}
scopeData中的productId
应该是什么?正如我已阅读其他一些帖子,据说productId
取自AVS Developer Portal中创建的应用的ID列,该列未与文档中的App Console提及Getting Started guide for iOS。所以我对如何/在哪里采取productId
感到困惑。
deviceSerialNumber
可以是任何唯一的字符串吗?
我在ObjC中实现了基于项目1)和2)中描述的代码质询方法,该方法在“将移动应用程序中的授权代码转移到支持Alexa的产品”部分中描述。这是对的吗? (因为我没有参考例子)
- (NSString *)codeChallenge {
verifier = [NSString randomStringWithLength:128]; // generate 128-char string containing [A-Z], [a-z], [0-9], "-", "_", ".", "~"
NSData *sha256 = [[verifier dataUsingEncoding:NSUTF8StringEncoding] SHA256]; // SHA256 that string
NSString *base64Enc = [sha256 base64EncodedStringWithOptions:0]; // base64 encode SHA256 result
NSLog(@"base64Enc: %@", base64Enc);
NSMutableString *ret = [NSMutableString string];
for (NSInteger i=0; i<base64Enc.length; i++) { // remove "="; replace "+" with "-"; replace "/" with "_" as referenced from: http://tools.ietf.org/html/draft-ietf-oauth-spop-10#appendix-A
unichar c = [base64Enc characterAtIndex:i];
if (c == '=') {
continue;
}
else if (c == '+') {
[ret appendString:@"-"];
}
else if (c == '/') {
[ret appendString:@"_"];
}
else {
[ret appendFormat:@"%C", c];
}
}
return ret;
}
此致
答案 0 :(得分:0)
因此,事实证明UILabel *lblUserQuestion = [[UILabel alloc] initWithFrame:CGRectMake(61, 25, self.frame.size.width-61-20, 37.0f)];
lblUserQuestion.numberOfLines= 0;
lblUserQuestion.font =[UIFont fontWithName:@"HelveticaNeue-Thin" size:14.];
lblUserQuestion.adjustsFontSizeToFitWidth = YES;
lblUserQuestion.minimumScaleFactor = 0.5;
lblUserQuestion.preferredMaxLayoutWidth= 100.0f;
lblUserQuestion.text = _photoToVote.label;
是App ID
。您应该能够在“应用程序类型信息”选项卡下的Developer Console中找到您的。您的代码挑战对我来说似乎很好,但我不确定您为什么要剥离productID
。是的,=+-_
可以是任何独特的东西,我假设每个安装它也应该是唯一的。
以下是Swift示例中的相同内容,
deviceSerailNumber