Google client-login in Objective-C

I am trying to write a code for google client-login in objective-c. I get Auth with email and password from "" and I can successfully login google by POSTER (firefox).

When I write the code for objective-c, however I cannot login and get error code 401.

Could someone help me what I am doing wrong? Here is my code.

// URL to check user info
NSURL *url = [NSURL URLWithString:@""];

// authorization 
NSString *auth = authString;

// create request
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];

// add auth information in header
auth = [NSString stringWithFormat:@"GoogleLogin auth=%@", auth];
[request addValue:auth forHTTPHeaderField:@"Authorization"];

// send request
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection) {
    NSLog(@"request send.");
} else {
    NSLog(@"Connection Failed when getting feeds.");


I have managed to log-in with Objective-C. I found my Header "Authentication" was null even though I set it in the code. I needed to remove %0A (in ASCII) to set the cookie.

Here is the modification I made. (Hope it would be helpful for someone)

// Encode ASCII
NSString * authEncoded = [auth stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

// Remove %0A
authEncoded =  [authEncoded stringByReplacingOccurrencesOfString:@"%0A" withString:@""];

// Create value for header
authEncoded = [[NSString alloc]initWithFormat:@"GoogleLogin auth=%@", authEncoded];

I used "authEncode" to set a header and everything works fine so far.

[request addValue:auth forHTTPHeaderField:@"Authorization"];

Need Your Help

Moving a DOM Element in jQuery (Layer Slider)

javascript jquery html wordpress dom

jQuery noob here. Sorry if the question is really simple, I haven't been exposed to much jquery, though I am trying to learn.

jSecurity JDBCRealm SQL setup

java sql security jdbc jsecurity

I am trying to use jSecurity for an enterprise java app, but the documentation is...well...lacking.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.