betfair / aping-ios-sdk

iOS SDK for APING
Other
4 stars 9 forks source link

Cannot log in #25

Open DarrenBranford opened 9 years ago

DarrenBranford commented 9 years ago

@seanoshea After successfully cloning the CocoaPod (thank you for fixing that) I found that I am unable to log in. The log message does not provide an error.

2015-03-20 15:20:37.081 RisingBetObjC[27020:1329145] There was an error while logging in (null) (null)

I added another NSLog to try to capture some more info.

2015-03-20 15:20:37.080 RisingBetObjC[27020:1329145] ssokey: (null), NSError: (null), BNGError: (null)

That seems to suggest that the ssoKey is not being generated/passed on.

For reference, my setup looks like this:

NSString *appKey    = @"E33v9H5bQlILMvtN";
NSString *scheme    = @"https";
NSString *product   = @"E33v9H5bQlILMvtN";
NSString *username  = @"Real_Username_Removed";
NSString *password  = @"Real_Password_Removed";

The appKey has been whitelisted and my client is enrolled in the vendor program.

Any help would be greatly appreciated.

seanoshea commented 9 years ago

@DarrenBranford I'll try to take a look at the weekend.

Can you double check with the Betfair (cc @jamiei) guys that the scheme should be https too? I think it might need to be something different, but I can't remember off the top of my head. My understanding is that the login mechanism is a little odd and while you'd think that https would be the logical scheme choice here, I think it changes on an app-by-app basis.

In the meantime, if you could post your the full code that you are using to try and authenticate to this bug report, it would help in figuring out what the root cause of the problem is. For example, does it look something like:

NSString *appKey    = @"E33v9H5bQlILMvtN";
NSString *scheme    = @"https";
NSString *product   = @"E33v9H5bQlILMvtN";
NSString *username  = @"Real_Username_Removed";
NSString *password  = @"Real_Password_Removed";

[[APING sharedInstance] registerApplicationKey:appKey ssoKey:nil];
// need to register the login URL protocol which the redirect url will hit once the login API call succeeds.
[BNGLoginURLProtocol registerWithScheme:scheme];

- (void)authenticateForUsername:(NSString *)username password:(NSString *)password product:(NSString *)product scheme:(NSString *)scheme
{
    NSURLRequest *request = [BNGAccount loginWithUserName:username password:password product:product redirectUrl:[scheme stringByAppendingString:@"://ios.betfair.com/login"] completionBlock:^(NSString *ssoKey, NSError *connectionError, BNGAPIError *apiError) {

    if (!connectionError && !apiError && ssoKey.length) {

If it looks something like that, it might be worthwhile to take a look at the connectionError and apiError variables in the callback block and see whether they have any additional information?

DarrenBranford commented 9 years ago

@seanoshea Thanks, I will double check the scheme. I was actually using the example project to try to log in, so the code is the same.

The connectionError and apiError are both null.

seanoshea commented 9 years ago

@DarrenBranford yep - I believe you can do a non-interactive login using HTTPS (ala a bot - most of the Betfair sample code are based off this), but the iOS APING client expects an interactive login as far as I can remember.

jamiei commented 9 years ago

@seanoshea What is *scheme used for in this instance?

The documentation for the non-interactive login (https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Interactive+Login+-+Desktop+Application) specifies both the non-interactive login URLs and the default redirect URLs as https.

seanoshea commented 9 years ago

@jamiei It's the redirectURL I believe. This is the url that identitysso POSTs back to when the login was successful. See the url parameter at https://github.com/betfair/aping-ios-sdk/blob/master/BNGAPI/BNGAPI/Classes/BNGAccount.m

DarrenBranford commented 9 years ago

@seanoshea Thanks for the clarification regarding interactive and non-interactive login; I had previously got the interactive login up and running before I came across this repository, but was experiencing "DSC-0024" when making any other calls to the API. I was hoping that the SDK would help me trace my problem.

seanoshea commented 9 years ago

Looks like DSC-0024 is:

@"DSC-0024" : @(BNGAPICougarErrorCodeRescriptDeserialisationFailure),

but I'm not sure what the correct recourse to that issue is. If we can figure out what the correct scheme parameter is for the login API call, I think all the rest of the API calls should fall into place.

nugster commented 9 years ago

@seanoshea the correct scheme is https but the login request still appears to be broken.

Can you confirm that the parameters required via BNGExampleViewController.m are used to construct the URL below?

https://identitysso.betfair.com/view/login?product=&url=

Using ://www.betfair.com instead of ://ios.betfair.com/login also doesn't work as the redirect URL for a white-listed App Key.

seanoshea commented 9 years ago

@nugster - yep, the parameters in the BNGExampleViewController are used to construct the login url.

bjm3 commented 8 years ago

Has this been fixed? I am having similar issues regarding logging in. I am using the sample BNGExampleApplication supplied with the API.