【问题标题】:How to use Authentication again after it was granted prevously先前授予身份验证后如何再次使用身份验证
【发布时间】:2015-08-22 12:30:43
【问题描述】:
-(void)getGoogleCalendar{    
GTLServiceCalendar *calendarService = self.calendarService;    
GTLQueryCalendar *calendarListQuery = [GTLQueryCalendar queryForCalendarListList];
[calendarService executeQuery:calendarListQuery completionHandler:^(GTLServiceTicket *ticket, GTLCalendarCalendarList * object, NSError *error) {       
    for (GTLCalendarCalendarListEntry *calendar in object.items) {
       [self getEventsForTheGivenCalendar:calendar.identifier];
    }        
    }];
}

登录后第一次运行完美,但应用程序启动后出现错误

Error Domain=com.google.GTLJSONRPCErrorDomain Code=401 "操作 无法完成。 (需要登录)“用户信息=0x79eb4f90 {error=需要登录,GTLStructuredError=GTLErrorObject 0x79fa9270: {消息:“需要登录”代码:401数据:[1]}, NSLocalizedFailureReason=(需要登录)}

我正在使用GTMOAuth2Authentication 身份验证进行登录并存储用户详细信息。如果用户详细信息不为零,则不会要求登录,然后在获取日历时发生错误。

如何在应用每次运行时获取 GTLCalendar?

【问题讨论】:

标签: ios google-calendar-api google-oauth


【解决方案1】:

您应该设置服务授权方以便能够进行查询。

calendarService.authorizer = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:KEYCHAINITEMNAME
                                                                           clientID:CLIENTID
                                                                       clientSecret:CLIENTSECRET];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-22
    • 2019-12-31
    • 2011-09-27
    • 2017-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多