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

api_key is missing error in example project #117

Closed
2 tasks
shahmirzali49 opened this issue Jul 22, 2021 · 5 comments
Closed
2 tasks

api_key is missing error in example project #117

shahmirzali49 opened this issue Jul 22, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@shahmirzali49
Copy link

shahmirzali49 commented Jul 22, 2021

Describe the bug

I download the example folder and run, then initialize API key, token and appID,

`  final client = StreamFeedClient.connect(
    _key,
    token: Token("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMTEzNDYxMSJ9.ROo1ALbUo03TEeTgd2dMZe6xSfRnenQsHtZUncqRXLU"),
    appId: "1134611",
  );`

but this gives this error when I click any user, for example, Sahil Kumar or any other.

`flutter: *** Request ***
flutter: uri: https://api.stream-io-api.com/api/v1.0/user/?get_or_create=true&api_key=&location=unspecified
flutter: method: POST
flutter: responseType: ResponseType.json
flutter: followRedirects: true
flutter: connectTimeout: 10000
flutter: sendTimeout: 0
flutter: receiveTimeout: 10000
flutter: receiveDataWhenStatusError: true
flutter: extra: {}
flutter: headers:
flutter:  stream-auth-type: jwt
flutter:  x-stream-client: stream-feed-dart-client-ios-0.2.2
flutter:  Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMTEzNDYxMSJ9.ROo1ALbUo03TEeTgd2dMZe6xSfRnenQsHtZUncqRXLU
flutter:  content-type: application/json; charset=utf-8
flutter: data:
flutter: User(sahil-kumar, {first_name: Sahil, last_name: Kumar, full_name: Sahil Kumar}, null, null, null, null)
flutter:
flutter: *** DioError ***:
flutter: uri: https://api.stream-io-api.com/api/v1.0/user/?get_or_create=true&api_key=&location=unspecified
flutter: DioError [DioErrorType.response]: Http status error [401]
#0      DioMixin.assureDioError
package:dio/src/dio_mixin.dart:819
#1      DioMixin._dispatchRequest
package:dio/src/dio_mixin.dart:678
<asynchronous suspension>
#2      DioMixin.fetch.<anonymous closure>.<anonymous closure> (package:dio/src/dio_mixin.dart)
package:dio/src/dio_mixin.dart:1
<asynchronous suspension>
flutter: uri: https://api.stream-io-api.com/api/v1.0/user/?get_or_create=true&api_key=&location=unspecified
flutter: statusCode: 401
flutter: headers:
flutter:  connection: keep-alive
flutter:  content-type: text/plain; charset=utf-8
flutter:  access-control-allow-origin: *
flutter:  date: Thu, 22 Jul 2021 11:51:33 GMT
flutter:  server: nginx
flutter:  content-length: 168
`

How can I solve this problem ?

What version of Flutter do you use?
Flutter 2.2.3
What package are you using? What version?
version 0.2.2

What platform is it about?

  • Android
  • iOS

✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-AZ)
• Flutter version 2.2.3 at /Users/shahmirzali/Development/flutter
• Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/shahmirzali/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (2 available)
• iPhone (mobile) • c47d4be7167357fd9af36d2acb585f38cc997040 • ios • iOS 14.4.2
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.164

• No issues found!

@shahmirzali49 shahmirzali49 added the bug Something isn't working label Jul 22, 2021
@sachaarbonel
Copy link
Member

Hey @Shahmirzali-Huseynov thanks for submitting an issue. Sounds like you didn't provide an api key. In the sample project we retrieve it from an environment variable that you have to set.

@shahmirzali49
Copy link
Author

@sachaarbonel thanks for support, but i set API key, but not working :(

@sachaarbonel
Copy link
Member

sachaarbonel commented Jul 29, 2021

By set you mean hardcoded or set via environment variable? If it is the later it's possible that on mobile it doesn't work. I also have something else in mind: is it your API key (copy pasted from your dashboard) or the API key from the tutorial?

@MisterJimson
Copy link

I ran into this too. You need to match the ID of the user you are clicking on with the ID you used to generate the token.

In my use case, I generated the user token like this in node.

const userToken = client.createUserToken('test');

And after I copied it into the Flutter app for testing, none of the user buttons worked. So I went into app_user.dart and modified Sahil's id to match mine.

const AppUser.sahil()
    : id = 'test',
      name = 'Sahil Kumar',

@xsahil03x xsahil03x added enhancement New feature or request and removed bug Something isn't working waiting for customer response labels Jul 30, 2021
@xsahil03x
Copy link
Contributor

@Shahmirzali-Huseynov the above solution which @MisterJimson shared will most probably solve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants