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

Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null. #11

Open
Mallikarjun7657 opened this issue Dec 22, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Mallikarjun7657
Copy link

While implementing oauth1 getting error after fetching ResourceOwnerAuthorizationURI.

Invoking the below function to perform oauth1 flow

`void authorizeOAuth1() async {
try {
// request temporary credentials (request tokens)
auth.requestTemporaryCredentials('oob').then((res) {
// redirect to authorization page
print("Open with your browser: ${auth.getResourceOwnerAuthorizationURI(res.credentials.token)}");

    // get verifier (PIN)
    stdout.write("PIN: ");
    String verifier = stdin.readLineSync();

    // request token credentials (access tokens)
    return auth.requestTokenCredentials(res.credentials, verifier);
  }).then((res) {
    // yeah, you got token credentials
    // create Client object
    var client = new oauth1.Client(platform.signatureMethod, clientCredentials, res.credentials);

    // now you can access to protected resources via client
    client.get('https://example.com/dailies').then((res) {
      print(res.body);
    });

    // NOTE: you can get optional values from AuthorizationResponse object
    print("Your screen name is " + res.optionalParameters['screen_name']);
  });
}catch(error, printStackTrace) {
  print('Exception => $error \n ${printStackTrace.toString()}');
}

}`

Below is the output from console

I/flutter (20805): Open with your browser: https://connect.garmin.com/oauthConfirm?oauth_token=81cd6ccb-ce41-408e-b1f5-609b141241d3
E/flutter (20805): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null.
E/flutter (20805): Receiver: null
E/flutter (20805): Tried calling: length
E/flutter (20805): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (20805): #1 _Uri._uriEncode (dart:core-patch/uri_patch.dart:44:23)
E/flutter (20805): #2 Uri.encodeComponent (dart:core/uri.dart:1065:17)
E/flutter (20805): #3 AuthorizationHeader._encodeParam (package:oauth1/src/authorization_header.dart:70:16)
E/flutter (20805): #4 AuthorizationHeader._createSignature. (package:oauth1/src/authorization_header.dart:96:40)
E/flutter (20805): #5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (20805): #6 AuthorizationHeader._createSignature (package:oauth1/src/authorization_header.dart:95:12)
E/flutter (20805): #7 AuthorizationHeader.toString (package:oauth1/src/authorization_header.dart:53:35)
E/flutter (20805): #8 Authorization.requestTokenCredentials (package:oauth1/src/authorization.dart:90:64)
E/flutter (20805): #9 _GarminAuthScreenState.authorizeOAuth1. (package:wear_poc/garmin/garmin_authentication_screen.dart:102:21)
E/flutter (20805): #10 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (20805): #11 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (20805): #12 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (20805): #13 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (20805): #14 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (20805): #15 Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (20805): #16 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter (20805): #17 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter (20805): #18 Authorization.requestTemporaryCredentials (package:oauth1/src/authorization.dart)
E/flutter (20805):
E/flutter (20805): #19 _GarminAuthScreenState.authorizeOAuth1 (package:wear_poc/garmin/garmin_authentication_screen.dart:93:12)
E/flutter (20805): #20 _GarminAuthScreenState.build. (package:wear_poc/garmin/garmin_authentication_screen.dart:53:19)
E/flutter (20805): #21 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter (20805): #22 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter (20805): #23 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (20805): #24 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (20805): #25 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (20805): #26 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7)
E/flutter (20805): #27 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9)
E/flutter (20805): #28 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
E/flutter (20805): #29 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (20805): #30 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (20805): #31 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (20805): #32 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (20805): #33 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
E/flutter (20805): #34 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
E/flutter (20805): #35 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
E/flutter (20805): #36 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
E/flutter (20805): #37 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
E/flutter (20805): #38 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
E/flutter (20805): #39 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (20805): #40 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (20805): #41 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (20805): #42 _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (20805): #43 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)

@kaetemi
Copy link
Member

kaetemi commented Jan 2, 2021

Change String verifier = stdin.readLineSync(); to String verifier = stdin.readLineSync() ?? '';

@kaetemi kaetemi added the enhancement New feature or request label Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants