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

NoSuchMethodError: The method 'cast' was called on null #64

Open
bat79a opened this issue Mar 16, 2021 · 6 comments
Open

NoSuchMethodError: The method 'cast' was called on null #64

bat79a opened this issue Mar 16, 2021 · 6 comments

Comments

@bat79a
Copy link

bat79a commented Mar 16, 2021

Hi all.

I just update the lib oauth2_client 1.3.0 to 1.7.1 but now my openid connection failed.

Here is the error message that I have :


[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The method 'cast' was called on null.
Receiver: null
Tried calling: cast<String>()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      TokenStorage.getToken.<anonymous closure> (package:oauth2_client/src/token_storage.dart:36:59)
#2      Iterable.firstWhere (dart:core/iterable.dart:513:15)
#3      TokenStorage.getToken (package:oauth2_client/src/token_storage.dart:28:40)
<asynchronous suspension>
#4      OAuth2Helper.getTokenFromStorage (package:oauth2_client/oauth2_helper.dart:105:12)
<asynchronous suspension>
#5      OAuth2Helper.getToken (package:oauth2_client/oauth2_helper.dart:80:19)
<asynchronous suspension>
#6      OAuth2Helper._request (package:oauth2_client/oauth2_helper.dart:287:19)
<asynchronous suspension>
#7      _MyHomePageState.apiUserInfo (package:myproject_mobile/main.dart:358:34)
<asynchronous suspension>

If someone can help me to fix this, it will be awesome.

Thx a lot.

@okrad
Copy link
Collaborator

okrad commented Apr 7, 2021

Hi @bat79a, can you try upgrading to the latest version (2.0.1)?

@ghost
Copy link

ghost commented Sep 22, 2021

I have the same issue during token refresh (version 2.2.2). In my case, AccessTokenResponse has null scope after AccessTokenResponse.fromHttpResponse.

@ernestoA92
Copy link

I'm having the same issue on version 2.3.0.

The problem is on this line:
package:oauth2_client/src/token_storage.dart:41:59

okrad added a commit that referenced this issue Dec 13, 2021
@okrad
Copy link
Collaborator

okrad commented Dec 13, 2021

Hi @ernestoA92, can you try with the newest release (2.3.1)?

@ghost
Copy link

ghost commented Dec 16, 2021

64

@xolf
Copy link
Contributor

xolf commented Jun 29, 2024

Hey guys,

I came across the same issue. Honestly, I'm not sure why access tokens with a null scope are being saved on the device, but I'm still encountering the error. I've opened a small PR that might resolve this problem.

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

4 participants