1. Current bug behavior
This used to work until I upgraded to the latest version of Flutter and Dart.
Code:
final oauth = TwitterOAuth2Client(
clientId: 'RGxNM2ZWeV94UUZFWGdLTDJmdzg6MTpjaQ',
clientSecret: '7E1YBMVA782yjeBowvAF_3sbidXvk9hJOmeGV_98fCf2K4teH5',
redirectUri: 'sportcast://',
customUriScheme: 'sportcast',
);
try {
var response = await oauth.executeAuthCodeFlowWithPKCE(
scopes: Scope.values,
);
I get the following exception when oauth.executeAuthCodeFlowWithPKCE is called:
_TypeError: type 'Null' is not a subtype of type 'String'
File "oauth_response.dart", line 25, in new OAuthResponse.fromJson
File "twitter_oauth2_client.dart", line 163, in _TwitterOAuth2Client._requestAccessToken
File "twitter_oauth2_client.dart", line 78, in _TwitterOAuth2Client.executeAuthCodeFlowWithPKCE
File "signup_controller.dart", line 176, in SignUpController.twitterAuth
File "auth_screen_widget.dart", line 61, in AuthScreenWidget.build.
...
(3 additional frame(s) were not displayed)
2. Expected behavior
I expect a successful login to Twitter.
3. Steps to reproduce
Twitter account is configured (dev) correctly. Keys are correct.
Run the code.
Get the error.
4. Flutter doctor output
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
✗ Unable to determine Android Studio version.
[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
[✓] VS Code (version 1.82.1)
[✓] Connected device (2 available)
[✓] Network resources
5. More environment information
import 'package:twitter_api_v2/twitter_api_v2.dart' as twitter_api;
import 'package:twitter_oauth2_pkce/twitter_oauth2_pkce.dart';
6. Log information
_TypeError: type 'Null' is not a subtype of type 'String'
File "oauth_response.dart", line 25, in new OAuthResponse.fromJson
File "twitter_oauth2_client.dart", line 163, in _TwitterOAuth2Client._requestAccessToken
File "twitter_oauth2_client.dart", line 78, in _TwitterOAuth2Client.executeAuthCodeFlowWithPKCE
File "signup_controller.dart", line 176, in SignUpController.twitterAuth
File "auth_screen_widget.dart", line 61, in AuthScreenWidget.build.
...
(3 additional frame(s) were not displayed)
7. More information
This used to work and suddenly stopped. Not sure if there were changed @ Twitter (X)