1

こんにちは、初めて質問を投稿します。間違いがあるかもしれません。だから私は、ユーザーが YouTube のものを管理できるようにする iOS アプリを作成したいと考えています。つまり、ユーザーが必要とする場合は、認証に oAuth2.0 Google API を使用する必要があります。

私が使用していた oAuth2 のサードパーティ コードは OAuth2Client です。数時間後、Google の認証ページにアクセスできるようになりました。しかし、[アクセスを許可] または [拒否] をクリックすると、ページが動かなくなりました。そのようなことを意図していたのか、それとも私のコードに問題があるのか​​ 疑問に思っています。

これがoAuth2の私のコードです

+ (void)initialize;
{
[[NXOAuth2AccountStore sharedStore]  setClientID:@"243181519584.apps.googleusercontent.com"
                                         secret:@"9b_K3C-kYp791Syga5K47cFS"
                                          scope:[NSSet setWithObject:@""]
                               authorizationURL:[NSURL URLWithString:@""]
                                       tokenURL:[NSURL URLWithString:@""]
                                    redirectURL:[NSURL URLWithString:@""]
                                 forAccountType:@"NBAvideo"];

}


//send request for logging in
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"NBAvideo"];


//add observer
[[NSNotificationCenter defaultCenter] addObserverForName:
 NXOAuth2AccountStoreAccountsDidChangeNotification     object:[NXOAuth2AccountStore sharedStore]
                                                   queue:nil
                                              usingBlock:^(NSNotification *aNotification){
                                                  NSLog(@"Success!");
                                                  }];

[[NSNotificationCenter defaultCenter] addObserverForName:NXOAuth2AccountStoreDidFailToRequestAccessNotification
                                                  object:[NXOAuth2AccountStore sharedStore]
                                                   queue:nil
                                              usingBlock:^(NSNotification *aNotification){
                                                  NSError *error = [aNotification.userInfo objectForKey:NXOAuth2AccountStoreErrorKey];
                                                  NSLog(@"Failure !");
                                              }];

[Allow Access] または [Deny] をクリックした後、ページの URL は私の redirect_url + code = ........,通知センターにオブザーバーを追加するときにアプリケーション サーバーが何も聞こえないため、どうすればそれを取得できるのだろうか. 製品登録時にgoogle api centerからリダイレクトURLを教えてもらったので、コードに「localhost」を使ってみたのですが、これでいいのかなぁ…。

ありがとうございました!

4

0 に答える 0