GithubHelp home page GithubHelp logo

twitter-dart / twitter-oauth2-pkce Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 12.0 336 KB

This library provides the optimized and easiest way to authenticate with Twitter's OAuth 2.0 PKCE in your Flutter app 🐦

Home Page: https://pub.dev/packages/twitter_oauth2_pkce

License: BSD 3-Clause "New" or "Revised" License

Dart 27.06% Kotlin 0.19% Swift 2.16% Objective-C 0.06% CMake 28.21% C++ 33.13% C 2.21% HTML 2.82% Ruby 4.17%
dart flutter oauth oauth2 oauth2-client pkce twitter twitter-api twitter-api-v2

twitter-oauth2-pkce's People

Contributors

bors[bot] avatar dependabot[bot] avatar myconsciousness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

twitter-oauth2-pkce's Issues

Error when `offline.access` scope is not specified

1. Current bug behavior

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      PlaygroundHomePage._fetchAccessToken (package:twitter_api_playground/src/service/view/home/home_page.dart:289:40)
<asynchronous suspension>
#1      PlaygroundHomePage.build.<anonymous closure> (package:twitter_api_playground/src/service/view/home/home_page.dart:49:31)
<asynchronous suspension>

2. Expected behavior

3. Steps to reproduce

4. Flutter doctor output

Output of: flutter doctor -v

5. More environment information

6. Log information

Enter log information in this code block

7. More information

PlatformException while attempting to Authorize App

1. Current bug behavior

While attempting to authorize the Twitter app, PlatformException(CANCELED) is thrown even though all the required credentials are provided.

2. Expected behavior

On successful authorization, the user should be rerouted to the app with the resulting query parameters.

3. Steps to reproduce

Run the example folder with the environment provided below.

4. Flutter doctor output

 Flutter (Channel stable, 3.0.3, on Ubuntu 22.04 LTS 5.15.0-40-generic,
    locale en_GB.UTF-8)
    • Flutter version 3.0.3 at /home/paperback/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 676cefaaff (11 days ago), 2022-06-22 11:34:49 -0700
    • Engine revision ffe7b86a1e
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /home/paperback/Android/Sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /home/paperback/dev/android/jre/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2021.2)
    • Android Studio at /home/paperback/dev/android
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension version 3.44.0

[✓] Connected device (3 available)
    • 2201117SG (mobile) • M7U8R87H9LHQ756P • android-arm64  • Android 11 (API
      30)
    • Linux (desktop)    • linux            • linux-x64      • Ubuntu 22.04 LTS
      5.15.0-40-generic
    • Chrome (web)       • chrome           • web-javascript • Google Chrome
      103.0.5060.53

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

5. More environment information

  • twitter_oauth2_pkce version: 0.4.0

6. More information

The underlying cause may be due to a bug in flutter_web_auth, is there a possible alternative to it?

Unable to process request due to missing initial state.

I am trying to use this in flutter web. As described here, I have added the auth.html file under the web folder. Still after clicking on 'Authorize the App' button, I am getting the error: Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

Here's my code:

Future<void> _signInWithTwitter() async {
    final oauth2 = TwitterOAuth2Client(
      clientId: 'xxxxxxxxxxxxxxxxxxxxxxx',
      clientSecret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      redirectUri: 'https://socialr-xxxxxxxxxx',
      customUriScheme: 'https',
    );

    final response = await oauth2.executeAuthCodeFlowWithPKCE(
      scopes: Scope.values,
    );

    global.accessToken = response.accessToken;
    global.refreshToken = response.refreshToken;
  }

Here's auth.html:

<!DOCTYPE html>
<title>Authentication complete</title>
<p>
  Authentication is complete. If this does not happen automatically, please
  close the window.
</p>
<script>
  window.opener.postMessage(
    {
      "https://socialr-xxxxxxxxxx":
        window.location.href,
    },
    window.location.origin
  );
  window.close();
</script>

Please help resolve this ASAP.

`TwitterOAuthException` must implement `Exception`

1. Current bug behavior

2. Expected behavior

3. Steps to reproduce

4. Flutter doctor output

Output of: flutter doctor -v

5. More environment information

6. Log information

Enter log information in this code block

7. More information

Login falied in case user has Twitter App

Hello..
If user has a Twitter application on the mobile, it will be moved to it and then the login process is not completed successfully
Especially if the Twitter app is closed, open it and then exit immediately
is there any way to prevent web url to go to twitter app?

Can't Redirect to App

1. Current bug behavior

  • after authorize app no,, auth successfully but, not redirect to App (without twitter app)
  • can't authorize if use twitter app

2. Expected behavior

  • After authorize app, automatic redirect to app

3. Steps to reproduce

i'have follow step :

  1. add activity Manifest scheme: app.name and host: callback
  2. in Twitter OAuth Client:
    -redirectUri: 'app.name://callback/'
    -customUriScheme: app.name

callback in Developer Portal : app.name://callback/

4. Flutter doctor output

[!] Flutter (Channel stable, 3.10.4, on macOS 11.3.1 20E241 darwin-x64, locale en-ID)
    • Flutter version 3.10.4 on channel stable at /Users/afdaldev/fvm/versions/stable
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.18.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/afdaldev/fvm/versions/stable. Consider adding /Users/afdaldev/fvm/versions/stable/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (4 weeks ago), 2023-06-05 18:04:56 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/afdaldev/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (3 available)
    • M2012K11AG (mobile) • 1029b3f0 • android-arm64  • Android 13 (API 33)
    • macOS (desktop)     • macos    • darwin-x64     • macOS 11.3.1 20E241 darwin-x64
    • Chrome (web)        • chrome   • web-javascript • Google Chrome 114.0.5735.198

[✓] Network resources
    • All expected network resources are available.

5. More environment information

6. Log information

Just this log after hit authorize app button
D/MiuiMultiWindowAdapter(17268): MiuiMultiWindowAdapter::getFreeformVideoWhiteListInSystem::LIST_ABOUT_SUPPORT_LANDSCAPE_VIDEO = [com.hunantv.imgo.activity, com.tencent.qqlive, com.qiyi.video, com.hunantv.imgo.activity.inter, com.tencent.qqlivei18n, com.iqiyi.i18n, tv.danmaku.bili]
D/AppScoutStateMachine(17268): 17268-ScoutStateMachinecreated
D/IS_CTS_MODE(17268): false
D/MULTI_WINDOW_ENABLED(17268): false

Getting TypeError: type 'Null' is not a subtype of type 'String' File "oauth_response.dart",

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.