我试图验证应用程序以使用他们的 API 访问 Vimeo。我似乎没有通过这个。我可以看到 vimeo 请求用户访问的页面,并在单击“允许”按钮时显示错误。我正在使用GTM-OAuth2
我添加了以下代码:
#import "ViewController.h"
#import "GTMOAuth2Authentication.h"
#import "GTMOAuth2ViewControllerTouch.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad{
[super viewDidLoad];
[self signInToVimeo];
}
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#define ClientID @"clientID"
#define ClientSecret @"clientSecret"
#define AuthURL @"https://api.vimeo.com/oauth/authorize"
#define TokenURL @"https://api.vimeo.com/oauth/request_token"
- (GTMOAuth2Authentication * )authForVimeo
{
//This URL is defined by the individual 3rd party APIs, be sure to read their documentation
NSURL * tokenURL = [NSURL URLWithString:TokenURL];
// We'll make up an arbitrary redirectURI. The controller will watch for
// the server to redirect the web view to this URI, but this URI will not be
// loaded, so it need not be for any actual web page. This needs to match the URI set as the
// redirect URI when configuring the app with Instagram.
NSString * redirectURI = @"Simple-OAuth2://";
GTMOAuth2Authentication * auth;
auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"Vimeo"
tokenURL:tokenURL
redirectURI:redirectURI
clientID:ClientID
clientSecret:ClientSecret];
auth.scope = @"public";
return auth;
}
- (void)signInToVimeo{
GTMOAuth2Authentication * auth = [self authForVimeo];
// Display the authentication view
GTMOAuth2ViewControllerTouch * viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth
authorizationURL:[NSURL URLWithString:AuthURL]
keychainItemName:@"VimeoKeychainItem"
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[self.navigationController pushViewController:viewController animated:YES];
}
- (void)viewController:(GTMOAuth2ViewControllerTouch * )viewController
finishedWithAuth:(GTMOAuth2Authentication * )auth
error:(NSError * )error
{
NSLog(@"finished");
NSLog(@"auth access token: %@", auth.accessToken);
[self.navigationController popToViewController:self animated:NO];
if (error != nil) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error Authorizing with Vimeo"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Success Authorizing with Vimeo"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
@end
我没有收到身份验证令牌。这是单击“允许”按钮的屏幕截图。