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

Failed assertion when doing clientViaUserConsent #26

Closed
floitsch opened this issue Dec 2, 2017 · 2 comments
Closed

Failed assertion when doing clientViaUserConsent #26

floitsch opened this issue Dec 2, 2017 · 2 comments

Comments

@floitsch
Copy link

floitsch commented Dec 2, 2017

When doing a clientViaUserConsent I get the following assertion error:

When running without assertions, the code seems to work.

Unhandled exception:
'package:googleapis_auth/src/auth_http_utils.dart': Failed assertion: line 81 pos 12: 'credentials.refreshToken != null': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/dart:core/errors_patch.dart:37)
#1      _AssertionError._throwNew (dart:core-patch/dart:core/errors_patch.dart:33)
#2      new AutoRefreshingClient (package:googleapis_auth/src/auth_http_utils.dart:81:12)
#3      clientViaUserConsent.<anonymous closure> (package:googleapis_auth/auth_io.dart:53:32)
#4      _RootZone.runUnary (dart:async/zone.dart:1381)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:129)
#6      _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
#7      _Future._propagateToListeners (dart:async/future_impl.dart:662)
#8      _Future._complete (dart:async/future_impl.dart:467)
#9      _SyncCompleter.complete (dart:async/future_impl.dart:51)
#10     _completeOnAsyncReturn (dart:async-patch/dart:async/async_patch.dart:255)
#11     AuthorizationCodeGrantServerFlow.run (package:googleapis_auth/src/oauth2_flows/auth_code.dart:223:9)
#12     _RootZone.runUnary (dart:async/zone.dart:1381)
#13     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#14     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
#15     _Future._propagateToListeners (dart:async/future_impl.dart:662)
#16     _Future._addListener.<anonymous closure> (dart:async/future_impl.dart:342)
#17     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#19     _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:376)
#20     _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:401)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
main() {
  clientViaUserConsent(new ClientId(_CLIENT_ID, _CLIENT_SECRET), _SCOPES, (String str) {
    print("asking for consent: $str");
  }).then((client) {
  });
@mkustermann
Copy link
Contributor

This issue should probably moved to package:googleapis_auth.

The assertion is correct in the sense that the oauth2 access token you got back will most likely only be valid for 1h and expire afterwards. Getting a refresh token from the server allows the returned AutoRefreshingAuthClient to refresh the access token before it expires. That's why the assertion is in.

The real question is why the server hasn't returned the refresh token in the first place.

@floitschG
Copy link

This issue was moved to dart-archive/googleapis_auth#26

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

No branches or pull requests

3 participants