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
認証トークンが届きません。これは、[許可] ボタンをクリックしたときのスクリーンショットです。