Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Issue when authorizing #1

Closed
ponnamkarthik opened this issue Jan 27, 2019 · 5 comments
Closed

Issue when authorizing #1

ponnamkarthik opened this issue Jan 27, 2019 · 5 comments
Labels
question Further information is requested

Comments

@ponnamkarthik
Copy link

ponnamkarthik commented Jan 27, 2019

E/flutter (11409): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (11409): NoSuchMethodError: The getter 'length' was called on null.
E/flutter (11409): Receiver: null
E/flutter (11409): Tried calling: length
E/flutter (11409): #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
E/flutter (11409): #1      _Uri._uriEncode (dart:core/runtime/liburi_patch.dart:44:23)
E/flutter (11409): #2      Uri.encodeComponent (dart:core/uri.dart:1060:17)
E/flutter (11409): #3      AuthorizationHeader._createSignature.<anonymous closure> (package:oauth1/src/authorization_header.dart:83:51)
E/flutter (11409): #4      __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
E/flutter (11409): #5      AuthorizationHeader._createSignature (package:oauth1/src/authorization_header.dart:82:12)
E/flutter (11409): #6      AuthorizationHeader.toString (package:oauth1/src/authorization_header.dart:55:35)
E/flutter (11409): #7      Authorization.requestTokenCredentials (package:oauth1/src/authorization.dart:94:36)
E/flutter (11409): <asynchronous suspension>
E/flutter (11409): #8      _MyHomePageState.getTwitterAsync.<anonymous closure> (package:flitter/main.dart:70:19)
E/flutter (11409): #9      _RootZone.runUnary (dart:async/zone.dart:1379:54)
E/flutter (11409): #10     _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (11409): #11     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
E/flutter (11409): #12     Future._propagateToListeners (dart:async/future_impl.dart:671:32)
E/flutter (11409): #13     Future._complete (dart:async/future_impl.dart:476:7)
E/flutter (11409): #14     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (11409): #15     _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
E/flutter (11409): #16     _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:295:13)
E/flutter (11409): #17     Authorization.requestTemporaryCredentials (package:oauth1/src/authorization.dart)
E/flutter (11409): <asynchronous suspension>
E/flutter (11409): #18     _MyHomePageState.getTwitterAsync (package:flitter/main.dart:60:10)
E/flutter (11409): #19     _MyHomePageState.initState (package:flitter/main.dart:38:5)
E/flutter (11409): #20     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3830:58)
E/flutter (11409): #21     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
E/flutter (11409): #22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #24     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
E/flutter (11409): #25     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #26     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #27     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
E/flutter (11409): #28     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
E/flutter (11409): #29     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
E/flutter (11409): #30     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
E/flutter (11409): #31     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #32     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #33     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
E/flutter (11409): #34     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #35     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #36     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
E/flutter (11409): #37     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #38     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #39     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
E/flutter (11409): #40     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #42     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
E/flutter (11409): #43     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
E/flutter (11409): #44     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
E/flutter (11409): #45     ComponentElement.perform
@kaetemi
Copy link
Member

kaetemi commented Jan 27, 2019

Thanks, will check. Any hints on reproducing?

@kaetemi
Copy link
Member

kaetemi commented Jan 27, 2019

Also, I recommend doing OAuth1 entirely server-side, just passing the result from getResourceOwnerAuthorizationURI to the app to show the authentication web page, and then passing the callback query back to the server.

For the callback url that contains the result query, for Twitter, use:

final oauth1.Platform platform = oauth1.Platform(
	provider.host + provider.requestTokenUrl,
	provider.host + provider.authenticateUrl,
	provider.host + provider.accessTokenUrl,
	oauth1.SignatureMethods.hmacSha1);
final oauth1.ClientCredentials clientCredentials = oauth1.ClientCredentials(
	provider.consumerKey, provider.consumerSecret);
final oauth1.Authorization oauth = oauth1.Authorization(
	clientCredentials, platform, httpClient);

final oauth1.Credentials credentials = oauth1.Credentials(
	query['oauth_token'],
	''); // oauth_token_secret can be left blank it seems
final oauth1.AuthorizationResponse authRes = await auth.requestTokenCredentials(
	credentials, query['oauth_verifier']);
oauthCredentials.token = authRes.credentials.token;
oauthCredentials.tokenSecret = authRes.credentials.tokenSecret;
oauthCredentials.tokenExpires = 0;
oauthCredentials.userId = authRes.optionalParameters['user_id'];

@ponnamkarthik
Copy link
Author

To reproduce the issue just use the example code you kept in Readme.md file

@kaetemi
Copy link
Member

kaetemi commented Jan 27, 2019

The example code is using PIN based authentication, and command line input.

Using command line input may be what's failing for you under Flutter.

@kaetemi
Copy link
Member

kaetemi commented Jan 27, 2019

final oauth1.AuthorizationResponse authRes =
    await auth.requestTemporaryCredentials(provider.callbackUrl);
final String authUrl = auth
    .getResourceOwnerAuthorizationURI(authRes.credentials.token);

To get the regular auth url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants