iphone - Integrate Box IOS sdk in my ios project -
i'm trying integrate box v2 ios sdk on ios project , integration fine, when try login , , after enter username , password , granted access , white screen , , boxapiauthenticationdidsucceed method not called , code the connexion method :
-(void) connecttobox { [boxsdk sharedsdk].oauth2session.clientid = @"my-client-id"; [boxsdk sharedsdk].oauth2session.clientsecret = @"my-client-secret"; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(boxapiauthenticationdidsucceed:) name:boxoauth2sessiondidbecomeauthenticatednotification object:[boxsdk sharedsdk].oauth2session]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(boxapiauthenticationdidfail:) name:boxoauth2sessiondidreceiveauthenticationerrornotification object:[boxsdk sharedsdk].oauth2session]; self.logincotroller = [[boxauthorizationviewcontroller alloc] initwithauthorizationurl:authorizationurl redirecturi:redirecturi]; [self presentviewcontroller:self.logincotroller animated:yes completion:nil]; }
and implement 2 methods :
- (void)boxapiauthenticationdidsucceed:(nsnotification *)notification; - (void)boxapiauthenticationdidfail:(nsnotification *)notification;
and notifications methods :
#pragma mark - handle oauth2 session notifications - (void)boxapiauthenticationdidsucceed:(nsnotification *)notification { boxoauth2session *session = (boxoauth2session *) notification.object; nslog(@"received oauth2 authenticated notification"); nslog(@"access token (%@) expires @ %@", session.accesstoken, session.accesstokenexpiration); nslog(@"refresh token (%@)", session.refreshtoken); dispatch_sync(dispatch_get_main_queue(), ^{ [self.logincotroller dismissviewcontrolleranimated:yes completion:nil]; }); } - (void)boxapiauthenticationdidfail:(nsnotification *)notification { nslog(@"received oauth2 failed authenticated notification"); nsstring *oauth2error = [[notification userinfo] valueforkey:boxoauth2authenticationerrorkey]; nslog(@"authentication error (%@)", oauth2error); dispatch_sync(dispatch_get_main_queue(), ^{ [self dismissviewcontrolleranimated:yes completion:nil]; }); }
i dont know wrong code.so if 1 can help.thanks
i'd suggest adding controller observer boxoauth2sessiondidrefreshtokensnotification call boxapiauthenticationdidsucceed: method. boxoauth2sessiondidrefreshtokensnotification posted when new access-token created/refresed.
Comments
Post a Comment