ios - Trouble with OAuth in Temboo -


i trying authorize twitter user in ios , temboo. here how attempting it.

in setttingsviewcontroller class have button user can tap begin twitterauthentication. have initializeoauth methods in class called twitterclient, , finalizeoauth methods in class called twitterfclient. here classes.

twitterclient.m

-(void)runinitializeoauthchoreo {     // instantiate choreo, using instantiated temboosession object, eg:     tmbtemboosession *session = [[tmbtemboosession alloc] initwithaccount:@"prnk28" appkeyname:@"floadt" andappkeyvalue:@"9b9031d182d7441da05f8214ba2c7170"];      // create choreo object using temboo session     tmbtwitter_oauth_initializeoauth *initializeoauthchoreo = [[tmbtwitter_oauth_initializeoauth alloc] initwithsession:session];      // inputs object choreo     tmbtwitter_oauth_initializeoauth_inputs *initializeoauthinputs = [initializeoauthchoreo newinputset];      // set credential use execution     [initializeoauthinputs setcredential:@"twitter"];      // set inputs     [initializeoauthinputs setforwardingurl:@"floadt://success"];      // execute choreo specifying class choreo delegate     [initializeoauthchoreo executewithinputs:initializeoauthinputs delegate:self]; }  // tmbchoreographydelegate method implementation - handle choreo errors -(void)choreographydidfailwitherror:(nserror*)error {     // log error console     nslog(@"error - %@", error); }  // tmbchoreographydelegate method implementation - choreo executed -(void)choreographydidfinishexecuting:(tmbtwitter_oauth_initializeoauth_resultset*)result {     // log results console    // nslog(@"%@", [result getauthorizationurl]);     [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:[result getauthorizationurl]]];      nsuserdefaults *user = [nsuserdefaults standarduserdefaults];      nsstring *callbackid = [result getcallbackid];     [user setobject:callbackid forkey:@"twittercallbackid"];     [user synchronize];      nsstring *oauthtokensecret = [result getoauthtokensecret];     [user setobject:oauthtokensecret forkey:@"twittertemporaryoauth"];     [user synchronize];  } 

twitterfclient.m

-(void)runfinalizeoauthchoreo {     // instantiate choreo, using instantiated temboosession object, eg:     tmbtemboosession *session = [[tmbtemboosession alloc] initwithaccount:@"prnk28" appkeyname:@"floadt" andappkeyvalue:@"9b9031d182d7441da05f8214ba2c7170"];      // create choreo object using temboo session     tmbtwitter_oauth_finalizeoauth *finalizeoauthchoreo = [[tmbtwitter_oauth_finalizeoauth alloc] initwithsession:session];      // inputs object choreo     tmbtwitter_oauth_finalizeoauth_inputs *finalizeoauthinputs = [finalizeoauthchoreo newinputset];      // set credential use execution     [finalizeoauthinputs setcredential:@"twitter"];      // set inputs     nsuserdefaults *user = [nsuserdefaults standarduserdefaults];     nsstring *tcall = [user stringforkey:@"twittercallbackid"];     nsstring *ttauth = [user stringforkey:@"twittertemporaryoauth"];     [finalizeoauthinputs setoauthtokensecret:tcall];     [finalizeoauthinputs setcallbackid:ttauth];     [finalizeoauthinputs setconsumerkey:twitter_consumer_key];     [finalizeoauthinputs setconsumersecret:twitter_consumer_secret];      // execute choreo specifying class choreo delegate     [finalizeoauthchoreo executewithinputs:finalizeoauthinputs delegate:self]; }  // tmbchoreographydelegate method implementation - handle choreo errors -(void)choreographydidfailwitherror:(nserror*)error {     // log error console     nslog(@"error - %@", error); }  // tmbchoreographydelegate method implementation - choreo executed -(void)choreographydidfinishexecuting:(tmbtwitter_oauth_finalizeoauth_resultset*)result {     // log results console     nslog(@"%@", [result getaccesstokensecret]);     nslog(@"%@", [result getaccesstoken]);     nslog(@"%@", [result getscreenname]);     nslog(@"%@", [result getuserid]); } 

those 2 client classes. believe in facebook example both combined suggested practice?

anyway how methods called within settingsviewcontroller class:

settingsviewcontroller.m

twitterclient *twitter = [[twitterclient alloc] init]; [twitter runinitializeoauthchoreo]; 

when user returns web browser when call finalizeoauth method. here how stated in appdelegate.

appdelegate.m

- (bool)application:(uiapplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication          annotation:(id)annotation {      nsstring *daurl = [url absolutestring];  //   nsstring *instagram;     nsstring *twitter;      twitter = [daurl substringwithrange: nsmakerange (0, 16)];    //  instagram = [daurl substringwithrange:nsmakerange(0, 27)];      if ([daurl isequal: @"floadt://success"]) {         twitterfclient *fo = [[twitterfclient alloc] init];         [fo runfinalizeoauthchoreo];     }else{         [[instagramclient sharedclient] handleoauthcallbackwithurl:url];     }      return yes; } 

im under assumption there simpler way , open drastic code change!

it looks have these values reversed:

[finalizeoauthinputs setoauthtokensecret:tcall]; [finalizeoauthinputs setcallbackid:ttauth]; 

also, in finalize step you're specifying twitter credential, you're doing this:

[finalizeoauthinputs setconsumerkey:twitter_consumer_key]; [finalizeoauthinputs setconsumersecret:twitter_consumer_secret]; 

that's unnecessary, since values stored in credential (as evidenced use of in initialize-oauth flow). can remove 2 lines altogether. if reason didn't match, choreo execution fail.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -