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 call failed | Forbidden request #392

Open
WaheedHussainHaans opened this issue Dec 29, 2023 · 7 comments
Open

Api call failed | Forbidden request #392

WaheedHussainHaans opened this issue Dec 29, 2023 · 7 comments
Labels
platform-android Specific to Android platform

Comments

@WaheedHussainHaans
Copy link

WaheedHussainHaans commented Dec 29, 2023

Code I am using

try {
                    final currentUser = FirebaseAuth.instance.currentUser;
                    await Intercom.instance.logout();
                    await Intercom.instance.loginIdentifiedUser(
                        userId: currentUser?.uid,
                        // email: currentUser?.email,
                        statusCallback:
                            IntercomStatusCallback(onFailure: (error) {
                          print('ERROR ${error.errorMessage}');
                        }));
                    await Intercom.instance.displayMessenger();
                  } catch (e) {
                    print("CATCHED ERRO $e");
                  }

Here are the logs I am getting

D/SessionLifecycleService( 7143): Activity backgrounding at 2864519
D/SessionLifecycleClient( 7143): Sending lifecycle 1 to service
D/EGL_emulation( 7143): app_time_stats: avg=77.97ms min=9.20ms max=2715.02ms count=45
D/SessionLifecycleService( 7143): Activity foregrounding at 2864661.
E/Intercom( 7143): Api call failed: {"error":"Forbidden request"}

Intercom version is intercom_flutter: ^8.0.3
Here is my Flutter Doctor -v output

Flutter (Channel stable, 3.16.1, on macOS 14.1.2 23B92 darwin-arm64, locale en-GB)
    • Flutter version 3.16.1 on channel stable at /Users/waheed/developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7f20e5d18c (5 weeks ago), 2023-11-27 09:47:30 -0800
    • Engine revision 22b600f240
    • Dart version 3.2.1
    • DevTools version 2.28.3
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/waheed/Library/Android/sdk
    • Platform android-34, build-tools 31.0.0
    • 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.6b829.9-10027231)
    • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.14.3
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
    • 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.6b829.9-10027231)
[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0
[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 12 (API 31)
      (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 14.1.2 23B92
      darwin-arm64
    • Chrome (web)                • chrome        • web-javascript • Google Chrome
      120.0.6099.129
[✓] Network resources
    • All expected network resources are available.
• No issues found!


Screenshot_1703837729

@deepak786
Copy link
Collaborator

The error in the logs is neither from the loginIdentifiedUser status callback nor from the catch block.
Before logging in the user, you are doing the logout. Do you have an Intercom user already logged in at that time?

@WaheedHussainHaans
Copy link
Author

The error in the logs is neither from the loginIdentifiedUser status callback nor from the catch block. Before logging in the user, you are doing the logout. Do you have an Intercom user already logged in at that time?

I tried removing the logout part and its still the same error

@NapoleonS
Copy link

I'm facing a similar issue, were you able to fix it?

@deepak786
Copy link
Collaborator

Can you provide reproducible sample?

@kanclalg
Copy link

I was facing a similar problem. The problem was that I was testing between intercom production and test environment and replaced androidApiKey only in one place here await Intercom.instance.initialize('appIdHere', iosApiKey: 'iosKeyHere', androidApiKey: 'androidKeyHere'); but forgot to change it in onCreate() here IntercomFlutterPlugin.initSdk(this, appId = "appId", androidApiKey = "androidApiKey").

In other words, make sure you're using the same androidApiKey in both places - when initiliazing it in onCreate() and in your flutter code.

@aghyad97
Copy link

aghyad97 commented Aug 1, 2024

Hey I had the same issue earlier and it turns out I have not enabled this option from Intercom Dashboard under Messenger/Install. Not sure if this will help you but it resolved the issue for me.
Best.

Screenshot 2024-08-01 at 2 41 06 PM

@JoshStrobl
Copy link

Something I fumbled with on iOS, be sure to set your data region in your Info.plist to AU or EU if that is your region. Otherwise it will default to US and while the initialize will be fine, login won't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android Specific to Android platform
Projects
None yet
Development

No branches or pull requests

6 participants