好的,所以我设置了我的端点api代码和我的iOS身份验证,正如谷歌平台文档中所提到的那样,但由于某种原因,在呈现OAuth2ViewControllerTouch视图控制器时我没有提示登录屏幕。
我的端点api如下所示:
@endpoints.api(
name='authed_api_calls',
version='v1',
# Only allowed configured Client IDs to access this API.
allowed_client_ids=ALLOWED_CLIENT_IDS,
# Only allow auth tokens with the given audience to access this API.
audiences=[ANDROID_AUDIENCE,WEB_CLIENT_ID],
# Require auth tokens to have the following scopes to access this API.
scopes=[endpoints.EMAIL_SCOPE])
class AuthedAPICalls(remote.Service):
@endpoints.method(
message_types.VoidMessage,
UserData,
path='get_cur_user',
http_method='GET',
name='get_cur_user')
def get_cur_user_email(self, unused_request):
######CODE FOR AUTHORIZING USER#######
user = endpoints.get_current_user()
ret_user = UserData()
if user is None:
raise endpoints.UnauthorizedException('Invalid token.')
else:
user_name = user.email()
ret_user.user_email = user_name
return ret_user
我的iOS代码如下。这是我得到黑屏的地方,因为我假设它没有达到auth网址:
GTMOAuth2Authentication *auth = [self setupAuth];
GTMOAuth2ViewControllerTouch *viewController;
viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth
authorizationURL:[NSURL URLWithString:authorizeURL_string]
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[[self navigationController] pushViewController:viewController animated:YES];
//commented out because I'm unsure of where it would try and authenticate to.
/*GTMOAuth2ViewControllerTouch *viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:OAuthScope
clientID:kMyClientID
clientSecret:kMyClientSecret
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[self presentViewController:viewController animated:YES completion:^(void){
//do stuff
}];*/
不用说代码永远不会到达选择器方法:viewController:finishedWithAuth:error:要么。
有谁知道为什么我没有看到任何结果?