从我这边我已经设置了所有访问goole驱动器,并且我在我的网站中使用了相同的steos它可以工作但是在iOS中我无法获得访问令牌。
我的代码是:
NSLog(@"Getting token from google...");
NSLog(@"Sending request");
NSMutableURLRequest *requestUrl = [[NSMutableURLRequest alloc] init ];
[requestUrl setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://accounts.google.com/o/oauth2/token?code=%@&client_id=75******6961-7ls48ks78ion3utj87rcm3rke8etkulh.apps.googleusercontent.com&client_secret=**********-DsOeg2t&redirect_uri=https://www.google.com&grant_type=authorization_code",code]]];
[requestUrl setHTTPMethod:@"POST"];
[requestUrl setValue:@"application/x-www-form-urlencode" forHTTPHeaderField:@"Content-Type"];
NSURLResponse *response;
NSError *err;
NSData *reponseData = [NSURLConnection sendSynchronousRequest:requestUrl returningResponse:&response error:&err];
NSString *res = [[NSString alloc] initWithData:reponseData encoding:NSASCIIStringEncoding];
NSLog(res);
我做错了什么?
回应是:
{
"error" : "invalid_request"
}