cameronr / GoogleAppEngineAuth

A few objective-c classes for implementing Google ClientLogin for use with Google App Engine
The Unlicense
35 stars 2 forks source link

Can't auth against ssl-protected pages #2

Closed vvanhee closed 13 years ago

vvanhee commented 13 years ago

It may be that I'm doing something wrong, but I can't seem to authenticate against pages protected with ssl. I get an "UnknownAppEngineClientError" when I try to use the https: url in "andAppURL:" And if I try to use https with my auth token after successfully authenticating with the http url address, it doesn't work... Any ideas?

gaea = [[GoogleAppEngineAuth alloc] initWithDelegate:self andAppURL:[NSURL URLWithString:@"http://supercoolapp.appspot.com"]];
[gaea authWithUsername:username andPassword:password withSource:@"mywebsite.info-coolapp-1.0"];

If I use http above and get an auth token, then I can't access the link below using https. If I use https in "andAppURL:" above, I get the "UnknownAppEngineClientError" and no auth token.

NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"https://supercoolapp.appspot.com/AuthTest"]];                
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:[NSString stringWithFormat:@"GoogleLogin auth=%@", auth] forHTTPHeaderField:@"Authorization"];
[request setValue:@"SuperCoolApp (gzip)" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
connectionLogin = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

Thanks for your help!

cameronr commented 13 years ago

You weren't doing anything wrong, the code just didn't support HTTPS app URLs. For those, the auth comes back in a different cookie (see http://stackoverflow.com/questions/3074679/why-am-i-getting-a-sacsid-cookie-from-google-appengine-login-instead-of-an-acsid/3147676#3147676). I've updated the code and it should work with an HTTPS app URL now. Let me know if it doesn't.

vvanhee commented 13 years ago

Works great! Thanks.