Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

twitter crashed #42

Closed
naviocean opened this issue Jan 15, 2017 · 46 comments
Closed

twitter crashed #42

naviocean opened this issue Jan 15, 2017 · 46 comments

Comments

@naviocean
Copy link

naviocean commented Jan 15, 2017

Hi guys,
I got a trouble that when I used method login with twitter: manager.authorize('twitter'), my app is crashed only on iOS. However, it works fine with both of facebook and google.
Beside that, when I set {scopes: 'email'} or {scopes: 'profile'} it returns ok but {scopes: 'email,profile'} return a error invalid_scope. How to get multiple scopes?

Please help me to solve this issue.
Thanks

@auser
Copy link
Contributor

auser commented Jan 15, 2017

Hm. I'm away from a keyboard this weekend, but can take a look when I get back. It's using the native twitter API. Do you have the crash logs?

If you use the latest version (master), you should see the URL it constructs (logging statement)

@naviocean
Copy link
Author

naviocean commented Jan 16, 2017

omg, I dont know what's happen but after run react-native log-ios, this issue went away. I can see the screen login twitter but can not catch response.data.

Warning: Possible Unhandled Promise Rejection (id:0)

note: android works fine.

@madebysquares
Copy link

I'm having this issue with iOS also.

@naviocean
Copy link
Author

I found a solution for scopes that's changed coma to plus {scopes: 'email+profile'}

@madebysquares
Copy link

@naviocean Thanks, that doesn't seem to work for me, it does appear to be an issue with the scoping/credentials are showing null.

@arilitan
Copy link
Contributor

arilitan commented Jan 17, 2017

@naviocean @auser I'm getting a crash as well trying to connect to twitter. Crash logs:
2017-01-16 17:45:32.269 Swish[15811:1835348] *** -[_NSActivityAssertion _initWithActivityOptions:reason:expirationHandler:]: Warning: Could not create system idle sleep assertion (-536870199) 2017-01-16 17:45:32.471 Swish[15811:1829373] called clearPendingAccount: <DCTOAuth1Account: 0x60000033a2c0; type = twitter; identifier = 4CCA3FA3-60A6-4498-A533-48544080E17B; credential = (null)> 2017-01-16 17:45:32.471 Swish[15811:1829373] *** Assertion failure in -[DCTAuthURLOpener close:], /Users/arilitan/Swish/SwishMobile/ios/Pods/DCTAuth/DCTAuth/DCTAuthURLOpener.m:57 2017-01-16 17:45:32.478 Swish[15811:1829373] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Object should be the object returned from openURL:withCallbackURL:handler:'

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Get the latest update. I pushed an update that fixes this problem.

@arilitan
Copy link
Contributor

@auser thanks for being on top of this. I downloaded the new version you published to npm, unfortunately I'm still getting the same crash

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Oh you are on iOS... lemme finish debugging this Android problem

@arilitan
Copy link
Contributor

@auser yep indeed. thanks again

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Alright, can you try with the latest push on master?

@madebysquares
Copy link

madebysquares commented Jan 17, 2017

Thanks for your help on this issue @auser but It's crashing logs are showing this error now:

Jan 16 22:28:09 NBCMac-0256 Logoed[74777] <Warning>: called clearPendingAccount: <DCTOAuth1Account: 0x6080003258c0; type = twitter; identifier = D7BF579A-7BDF-47A2-A524-60C0CC2C4401; credential = (null)>
Jan 16 22:28:09 NBCMac-0256 Logoed[74777] <Warning>: *** Assertion failure in -[DCTAuthURLOpener close:], /Users/harryalford/Sites/workbook/raw/Logoed/ios/Pods/DCTAuth/DCTAuth/DCTAuthURLOpener.m:57
Jan 16 22:28:09 NBCMac-0256 Logoed[74777] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Object should be the object returned from openURL:withCallbackURL:handler:'
	*** First throw call stack:
	(
		0   CoreFoundation                      0x000000010ee11d4b __exceptionPreprocess + 171
		1   libobjc.A.dylib                     0x000000010d90321e objc_exception_throw + 48
		2   CoreFoundation                      0x000000010ee15e42 +[NSException raise:format:arguments:] + 98
		3   Foundation                          0x000000010d49866d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
		4   DCTAuth                             0x000000010b893aea -[DCTAuthURLOpener close:] + 314
		5   DCTAuth                             0x000000010b884c0c +[DCTAuth cancelOpenURL:] + 92
		6   DCTAuth                             0x000000010b8999ed -[DCTOAuth1Account cancelAuthentication] + 77
		7   Logoed                              0x000000010b4a7c73 -[OAuthClient clearPendingAccount] + 115
		8   Logoed                              0x000000010b4a874d __59-[OAuth1Client authorizeWithUrl:url:cfg:onSuccess:onError:]_block_invoke + 109
		9   DCTAuth                             0x000000010b898853 __44-[DCTOAuth1Account authenticateWithHandler:]_block_invoke.66 + 1075
		10  DCTAuth                             0x000000010b899482 __44-[DCTOAuth1Account authenticateWithHandler:]_block_invoke.131 + 130
		11  DCTAuth                             0x000000010b890574 __44-[DCTAuthRequest performRequestWithHandler:]_block_invoke_2 + 116
		12  libdispatch.dylib                   0x0000000111a9f808 _dispatch_call_block_and_release + 12
		13  libdispatch.dylib                   0x0000000111ac112e _dispatch_client_callout + 8
		14  libdispatch.dylib                   0x0000000111aa84fb _dispatch_main_queue_callback_4CF + 1054
		15  CoreFoundation                      0x000000010edd5e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
		16  CoreFoundation                      0x000000010ed9b37d __CFRunLoopRun + 2205
		17  CoreFoundation                      0x000000010ed9a884 CFRunLoopRunSpecific + 420
		18  GraphicsServices                    0x0000000112b0fa6f GSEventRunModal + 161
		19  UIKit                               0x000000010bb7cc68 UIApplicationMain + 159
		20  Logoed                              0x000000010b49f2ef main + 111
		21  libdyld.dylib                       0x0000000111b0a68d start + 1
		22  ???                                 0x0000000000000001 0x0 + 1
	)

I pulled in the latest version from npm 2.1.13

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Can you share your code, by chance? I am having trouble trying to recreate the error here...

@naviocean
Copy link
Author

Hi @auser ,
After updated lastest version 2.1.13, the issue cant catched response.data is still occured.

@madebysquares
Copy link

madebysquares commented Jan 17, 2017

// oauthmanager.js
import OAuthManager from 'react-native-oauth'
const config =  {
  twitter: {
    consumer_key: 'Cxxxxx',
    consumer_secret: '7xxxx'
  }
}

const manager = new OAuthManager('XXXX')
manager.configure(config)

export function authorize(success, failure) {
  console.log(manager)


  manager.authorize('twitter', {scopes: 'profile,email'})
    .then(success)
    .catch(failure)
}

And I call it by:

import * as oauth from 'oauthmanager'

oauth.authorize()

@auser : As soon as it calls manager.authorize() whole app crashes.

@auser
Copy link
Contributor

auser commented Jan 17, 2017

@madebysquares do you have any adb logs you could share?

You can get them using this command (substituting your app id, of course):

adb logcat | grep $(adb shell ps | grep -i com.firestackapp | cut -c10-15)

@arilitan
Copy link
Contributor

arilitan commented Jan 17, 2017

@auser looks like @madebysquares is also having the issue on iOS - same error I was seeing as well. below is my code if it helps:

const config =  {
  twitter: {
    consumer_key: 'Cxxx',
    consumer_secret: '8xxx'
  }
}

const manager = new OAuthManager('swish')
// configure the manager
manager.configure(config);

function connectTwitter(): ThunkAction {
  const thunk = (dispatch, getState) => {
    manager.authorize('twitter', {scopes: 'email'})
    .then(resp => console.log(resp))
    .catch(err => console.log(err));
  }
  return thunk
}

when I call the connectTwitter action the app crashes

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Is this on iOS?

@arilitan
Copy link
Contributor

yes

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Okay, so I was able to duplicate this issue and fix it.

  • Did you update your AppDelegate.m as the README.md shows?
  • Make sure you link libOauthManager.h
  • Did you add the URL types to your project?
  • Did you link the LinkingManager?

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Feel free to reopen this issue if it still exists after all the steps on the README are setup in your app.

@auser auser closed this as completed Jan 17, 2017
@arilitan
Copy link
Contributor

arilitan commented Jan 17, 2017

@auser yes I followed every step as described above, went back and double checked. still happening unfortunately. i dont have the ability to re-open the issue since i didn't create this one

@arilitan
Copy link
Contributor

@madebysquares let us know if you have any luck

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Did you rebuild your application after updating your app? Set a breakpoint in your AppDelegate.m on the handleOpenUrl method. Does that ever get triggered?

@auser
Copy link
Contributor

auser commented Jan 17, 2017

Happy to jump on ScreenHero to debug with you.

@arilitan
Copy link
Contributor

handleOpenUrl doesn't ever get triggered. the app is crashing on this line: https://github.com/fullstackreact/react-native-oauth/blob/master/ios/OAuthManager/OAuth1Client.m#L34

screenhero would be awesome i sent you an invite - not sure how to add ppl outside my slack org. I'm ari@swish.io

@arilitan
Copy link
Contributor

for what its worth facebook login is working fine so i think the library is properly installed?

@auser
Copy link
Contributor

auser commented Jan 17, 2017

I stepped away for a few minutes. Will be back in about one hour.

@madebysquares
Copy link

Yes, I followed all the steps, I'm only working with iOS currently. Facebook works perfectly fine, (as @arilitan mentioned for him). I will pull the latest 2.1.14 and try again in a bit.

@adrianotadao
Copy link

Hello guys... I'm having the same error as @madebysquares.

@auser thank you for this lib, that is really awesome!

@madebysquares
Copy link

Still getting this error:

<Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Object should be the object returned from openURL:withCallbackURL:handler:'

@auser
Copy link
Contributor

auser commented Jan 18, 2017

Thanks to @arilitan, we merged a patch that will give better error responses. Can you try pulling the latest version (2.1.15) and see what error response comes out in the iOS terminal?

@auser auser reopened this Jan 18, 2017
@naviocean
Copy link
Author

naviocean commented Jan 18, 2017

Hello @auser, I've updated to 2.1.15, on IOS the warning promise is disappeared but nothing is returned.

manager.authorize('twitter')
      .then((response) => {
        console.log(response);
      })
      .catch((error) => {
        Alert.alert('Error', 'Can not login to Twitter');
      });

2017-01-18 19:32:15.130 okeeDeals[5743:110214] Calling authorizeWithUrl: twitter with callbackURL: OkeeDeals://oauth-response/twitter
{
"access_token_url" = "https://api.twitter.com/oauth/access_token";
"api_url" = "https://api.twitter.com";
"app_name" = OkeeDeals;
"auth_version" = "1.0";
"authorize_url" = "https://api.twitter.com/oauth/authorize";
"callback_url" = "OkeeDeals://oauth-response/twitter";
"consumer_key" = xxxxxx;
"consumer_secret" = xxxxxxxxx;
"request_token_url" = "https://api.twitter.com/oauth/request_token";
}

2017-01-18 19:25:15.004 okeeDeals[5644:104381] called clearPendingAccount: <DCTOAuth1Account: 0x600000132340; type = twitter; identifier = 91BFBFE4-D890-41D1-B34B-60CCF08A7857; credential = (null)>

Note: fb and google work fine on IOS

@madebysquares
Copy link

@auser

Jan 18 11:27:37 NBCMac-0256 Logoed[34652] <Warning>: Error in authorizeWithUrl: Error Domain=DCTAuth Code=0 "(null)" UserInfo={response=HTTP/1.1 0 Server Error

	<?xml version="1.0" encoding="UTF-8"?>
	<hash>
	  <error>Desktop applications only support the oauth_callback value 'oob'</error>
	  <request>/oauth/request_token</request>
	</hash>


	}

@arilitan
Copy link
Contributor

@madebysquares @naviocean we figured out you need to add a callback URL in your app settings. It doesn't matter what it is just has to be a valid URL. That should resolve it - see the highlighted field below:

screen shot 2017-01-18 at 10 13 32 am

@adrianotadao
Copy link

adrianotadao commented Jan 18, 2017

@arilitan you are right! I tested here and everything is working well. hahahaha I don't believe that!

@madebysquares
Copy link

@arilitan yes that works. Thanks to you and thanks @auser for your time debugging this, wish the error message would have been more helpful from twitter.

@auser auser closed this as completed Jan 19, 2017
@PranayShah
Copy link

Beside that, when I set {scopes: 'email'} or {scopes: 'profile'} it returns ok but {scopes: 'email,profile'} return a error invalid_scope. Ditto here, developing on Windows for Android and v 2.1.15. Another issue is, the rnpm prelink and postlink commands are .sh files, hence throw an error when linking on Windows.

@naviocean
Copy link
Author

@PranayShah try to set {scopes:'email+profile'}
@arilitan I've set callback url in app setting but my issue is still occured.

@PranayShah
Copy link

PranayShah commented Jan 20, 2017

@naviocean Tried it, no luck. The error is {invalid=[profile+email]}

@adrianotadao
Copy link

I'm having the same error like @PranayShah but, on google.

@auser
Copy link
Contributor

auser commented Jan 20, 2017

Regarding the scopes, they should be comma (,) separated.

Does it work @adrianotadao with just a single scope?

@PranayShah
Copy link

PranayShah commented Jan 20, 2017 via email

@adrianotadao
Copy link

@auser yes, with a single scope it works very well.

@tomjohnhall
Copy link

For the benefit of anyone looking at this thread as of June 2018, they may find this page in the twitter docs is enlightening.

You will need to add a valid callback URL in twitter settings. Should be {your_app_name}://

check the log for

calling authorizeWithUrl

and make sure the callbackURL sent there matches your settings, but just the protocol (eg sent 'callback_url' will be 'exampleapp://oauth-response/twitter' so twitter settings callback url needs to be 'exampleapp://' )

The docs should probably be updated to reflect what appears to be a very recent change.

@bjacog
Copy link

bjacog commented Jan 23, 2019

@tomjohnhall thank you for mentioning authorizeWithUrl for me it kept trying to callback to 'twitter://`.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants