0

I'm working with iOS application which is used to authenticate with Google oAuth2 mechanism. After successfully authentication, i've to send code/token to the server for handling the sync of files, calendars, etc.
I'm able to successfully authenticate with google using their latest library/framework.
But after authentication, i got the token/code which I can send to server. But when server is using the code to authenticate with google, its failing.
Is there any other API to handle this?

Satyam
  • 15,493
  • 31
  • 131
  • 244

1 Answers1

0

It's very broad theme :) In some cases there's enough to add token data to URL, like LinkedIn, for example:

NSString *requestURLString = [@"https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=" stringByAppendingString:@"LI_access_token"];

And in some cases adding corresponding fields to HTTP POST-request is necessary, like posting Facebook like for example:

postString = [NSString stringWithFormat:@"\r\n--%@\r\n", boundary];
postString = [postString stringByAppendingString:@"Content-Disposition: form-data; name=\"access_token\"\r\n\r\n"];
postString = [postString stringByAppendingString:FBSession.activeSession.accessTokenData.accessToken];

Or adding additional fields to HTTP-request header is needed, like SoundCloud, for example:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0f];
[request setHTTPMethod:@"GET"];
[request setValue:[@"OAuth " stringByAppendingString:self.accessToken] forHTTPHeaderField:@"Authorization"];

Try to clarify your case with documentation of used API.

Sergei Nikitin
  • 788
  • 7
  • 12