【问题标题】:Vimeo API OAuth 2.0 for iOS - Authentication token not received适用于 iOS 的 Vimeo API OAuth 2.0 - 未收到身份验证令牌
【发布时间】:2014-03-29 06:55:03
【问题描述】:

我试图验证应用程序以使用他们的 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

我没有收到身份验证令牌。 Here 是点击“允许”按钮的屏幕截图。

【问题讨论】:

    标签: ios oauth vimeo-api


    【解决方案1】:

    您的客户端 ID 和客户端密码应该是您从 Vimeo 开发者网站获得的,而不是“clientID”/“clientSecret”。

    【讨论】:

    • 你认为他会把他真实的client_id和client_secret放在他的帖子里吗?
    猜你喜欢
    • 2014-12-24
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多