Skip to content

The documentation of StreamFeedClient is no correct #228

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

Open
6 tasks done
ValentinVignal opened this issue May 26, 2022 · 1 comment
Open
6 tasks done

The documentation of StreamFeedClient is no correct #228

ValentinVignal opened this issue May 26, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@ValentinVignal
Copy link

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?

  • Android
  • iOS
  • Web
  • Windows
  • MacOS
  • Linux

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.

@ValentinVignal ValentinVignal added the bug Something isn't working label May 26, 2022
@sachaarbonel sachaarbonel added documentation Improvements or additions to documentation and removed bug Something isn't working labels May 27, 2022
@sachaarbonel
Copy link
Member

sachaarbonel commented May 27, 2022

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),
  );

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

No branches or pull requests

2 participants