@bossylobster にご協力いただきありがとうございます。私は常にローカル開発サーバーで http を使用していましたが、本当の問題は、iOS OAuth2 ライブラリが非 https リクエストを承認しないことでした。つまり、認証された呼び出しをローカルでテストできませんでした。
最終的GTMOAuth2Authentication
に、iOS OAuth2 ライブラリのクラスに、ライブラリがすべてのリクエスト (非 https を含む) を承認できるようにするフラグを見つけました。
// Property indicating if this object will authorize plain http request
// (as well as any non-https requests.) Default is NO, only requests with the
// scheme https are authorized, since security may be compromised if tokens
// are sent over the wire using an unencrypted protocol like http.
@property (assign) BOOL shouldAuthorizeAllRequests;
デフォルトでは、このフラグは false/NO に設定されています。リクエストで機能するようにこのフラグを更新するために、API リクエストを作成する前に OAUTH コールバック メソッドで値を変更しました。
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
[self dismissViewControllerAnimated:YES completion:nil];
if (error != nil) {
// Authentication failed
...
} else {
// Authentication succeeded
...
// TODO: for development purposes only to use non-https....remove for release.
auth.shouldAuthorizeAllRequests = YES;
// Make some API calls
...
}
}
この変更を行うと、iOS ライブラリはローカルの開発サーバーへの非 https リクエストを承認しました。このフラグは開発目的でのみ使用する必要があることに注意してください。