question

ardajm avatar image
ardajm asked

iOS SSL Error on [AIMobileLib authorizeUserForScopes...]

I'm using the original Reference Implementation Code for iOS, but I want to obtain just the token (I want the iOS App to talk to AVS directly) - I don't want the authorization code. From other forum questions/answers, I understand the code below should work When I run the app (simulator and device) I get the login screen, then when I submit, I get the error: [b]An SSL error has occurred and a secure connection to the server cannot be made.[/b] I cannot get to the DidSucceed method. On dismiss error I'm returned to the app. NOTE: Tried the following: I can get the LoginWithAmazon sample to work. Set the iOS 9 setting for Info.plist (NSAppTransportSecurity stuff) even though I'm not compiling for iOS 9 - still no joy. All my settings are for the companion app iOS all set up in the dev portal, etc. Any ideas what I'm doing wrong?? -(void) doLogin { NSArray *requestScopes = [NSArray arrayWithObjects:@"alexa:all", nil]; NSMutableDictionary *options = [[NSMutableDictionary alloc] init]; NSString* scopeData = [NSString stringWithFormat:@"{\"alexa:all\":{\"productID\":\"%@\"," "\"productInstanceAttributes\":{\"deviceSerialNumber\":\"%@\"}}}", @"my_device", @"123456"]; options[kAIOptionScopeData] = scopeData; [AIMobileLib authorizeUserForScopes:requestScopes delegate:self options:options]; } - (void) requestDidSucceed:(APIResult *) apiResult { // remainder of code - never get here!!! } - (void)requestDidFail:(APIError *) errorResponse { // get here every time... NSLog(@"In DidFail"); // Notify the user that authorization failed [[[UIAlertView alloc] initWithTitle:@"" message:[NSString stringWithFormat:@"User authorization failed with message: %@", errorResponse.error.message] delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil] show]; }
alexa voice service
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

elstryan@Amazon avatar image
elstryan@Amazon answered
Hi ardajm, Can you verify a few things for me. The sample code that you are using is from the zip that was downloaded as directed here: https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/reference-implementation-guide#Building%20and%20Running%20the%20Android%20and%20iOS%20Mobile%20Apps? Have you entirely removed the ProvisioningClient?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ardajm avatar image
ardajm answered
Yes, this is the code I am using. If I include the java client (which provides the code challenge values) I can retrieve the authorization code, but as soon as I remove the code challenge options (below) I get the SSL Error: Tried removing: kAIOptionReturnAuthCode:@YES, kAIOptionCodeChallenge:self.codeChallenge, kAIOptionCodeChallengeMethod:@"S256" Leaving the line: NSDictionary *options = @{kAIOptionScopeData:scopeData};
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

elstryan@Amazon avatar image
elstryan@Amazon answered
I suspect what is wrong here is that you still have code which is calling into the java client. Make sure that you have removed all of ProvisioningClient.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ardajm avatar image
ardajm answered
I had already commented out the client code. Found the issue by comparing to the LoginWithAmazon sample. Turns out the AlexaCompanionAppSample was missing the plist entry below (well it actually didn't seem to need it). When I added this entry to the AlexaCompanionAppSAmple.plist file I can successfully login. NSAppTransportSecurity NSExceptionDomains api.amazon.com NSExceptionRequiresForwardSecrecy
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

elstryan@Amazon avatar image
elstryan@Amazon answered
That does make sense. Thanks ardajm for pointing that out to us we'll add this to our defect tracking system and update the sample. We only use the companion app for the companion flow where that exception isn't necessary. However I do think it will make the sample better if we add this to reduce friction for users who want to convert the sample to something that hits AVS directly.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.