我正在制作一个iOS应用程序,它使用用户的谷歌帐户从他的YouTube帐户中获取数据并显示它们....第一步是使用gtm2来验证用户并获取访问令牌和刷新令牌问题是访问令牌在60分钟后到期,我必须登录并再次允许应用程序...我发现您可以使用刷新令牌从文档中使用此获取新的访问令牌: - >我的问题是如何发出POST请求以获取objective-c中的访问令牌这是我需要使用的数据:
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
client_id=21302922996.apps.googleusercontent.com&
client_secret=XTHhXh1SlUNgvyWGwDk1EjXB&
refresh_token=1/6BMfW9j53gdGImsixUH6kU5RsR4zwI9lUVX-tqf8JXQ&
grant_type=refresh_token
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码:
NSString *post =[[NSString alloc] initWithFormat:@"client_secret=%@&grant_type=refresh_token&refresh_token=%@&client_id%@",kGoogleClientSecretKey,kRefreshToken,kGoogleClientIDKey];
NSLog(@"%@",post);
NSURL *url=[NSURL URLWithString:@"https://accounts.google.com/o/oauth2/token"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:{"error":"invalid_request"}
我正在尝试使用 XCode 10 (10A255) 使用 Fastlane 制作我的库的胖二进制文件:
xcodebuild(
workspace: "Mylibrary.xcworkspace",
scheme: "Mylibrary",
configuration: "Release",
clean: true,
archive: true
)
Run Code Online (Sandbox Code Playgroud)
但是运行lipo -i ~/Mylibrary.framework/Mylibrary我只得到armv7 arm64不能在模拟器上运行的。
有谁知道发生这种情况的原因?
PS:相同的命令适用于 Xcode 9.4 和 lipo -i 打印i386 x86_64 armv7 arm64,效果很好。