GetStream / stream-feed-flutter

Stream Feed official Flutter SDK. Build your own feed experience using Dart and Flutter.
https://getstream.io
Other
71 stars 69 forks source link

The documentation of `StreamFeedClient` is no correct #228

Open ValentinVignal opened 2 years ago

ValentinVignal commented 2 years ago

Describe the bug The documentation of StreamFeedClient is no correct.

We can read in the documentation:

  /// - Instantiate a new client (server side) with [StreamFeedClient.connect]
  /// using your api [secret] parameter and [apiKey]
  /// ```dart
  /// var client = StreamFeedClient('YOUR_API_KEY',secret: 'API_KEY_SECRET');
  /// ```
  /// - Create a token for user with id "the-user-id"
  /// ```dart
  /// var userToken = client.frontendToken('the-user-id');
  /// ```
  /// - if you are using the SDK client side, get a userToken in your dashboard
  /// and pass it to [StreamFeedClient] using the [token] parameter
  /// and [apiKey]
  /// ```dart
  /// var client = StreamFeedClient('YOUR_API_KEY',token: Token('userToken'));
  /// ```

However, the StreamFeedClient factory does not have a token parameter:

  factory StreamFeedClient(
    String apiKey, {
    String? secret,
    String? appId,
    StreamHttpClientOptions? options,
    Runner runner = Runner.client,
    StreamAPI? api,
    String fayeUrl = 'wss://faye-us-east.stream-io-api.com/faye',
    Level logLevel = Level.WARNING,
    LogHandlerFunction? logHandlerFunction,
  });

So where am I supposed to pass the user token? I run my app on the client side (front end), so when I try to pass the secret I get the error:

 Unhandled Exception: Assertion failed: "You are publicly sharing your App Secret. Do not expose the App Secret in `browsers`, `native` mobile apps, or other non-trusted environments. "

What version of Flutter do you use?

Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (5 weeks ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

What package are you using? What version?

stream_feed version 0.5.2.

What platform is it about?

a copy of flutter doctor --verbose

[✓] Flutter (Channel stable, 2.10.5, on macOS 11.5.1 20G80 darwin-x64, locale en-GB)
    • Flutter version 2.10.5 at /Users/valentin/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (5 weeks ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /usr/local/Caskroom/android-sdk/4333796
    • Platform android-31, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2021.1)
    • 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 11.0.11+0-b60-7590822)

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

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 6D1E9DF8-540C-4307-89E7-FC2D14CF27B8 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 11.5.1 20G80 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 101.0.4951.64

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

• No issues found!

To Reproduce See description above

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Logs Run flutter analyze and attach any output of that command below. If there are any analysis errors, try resolving them before filing this issue.

NA

Additional context Add any other context about the problem here.

sachaarbonel commented 2 years ago

Hey sorry about that, this is indeed a doc issue. To set the user token you have to do it like that:

  await client.setUser(
    const User(
      id: 'GroovinChip',
      data: {
        'handle': '@GroovinChip',
        'first_name': 'Reuben',
        'last_name': 'Turner',
        'full_name': 'Reuben Turner',
        'profile_image': 'https://avatars.githubusercontent.com/u/4250470?v=4',
      },
    ),
    const Token(userToken),
  );