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

🔥new OAuthProvider()` is not supported on the native Firebase SDKs. (Even though it is) #3926

Closed
1 of 9 tasks
zaptrem opened this issue Jul 12, 2020 · 13 comments
Closed
1 of 9 tasks
Labels
Service: Authentication Firebase Authentication Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@zaptrem
Copy link

zaptrem commented Jul 12, 2020

Issue

Getting new OAuthProvider()` is not supported on the native Firebase SDKs.
When running var provider = new firebase.auth.OAuthProvider('zoom.com');
This definitely isn't true. See here and here.

Likely related to this check in your unit tests (along with potentially no implementation?)

  describe('OAuthProvider', () => {
     describe('constructor', () => {
       it('should throw an unsupported error', () => {
         (() => new firebase.auth.OAuthProvider()).should.throw(
           '`new OAuthProvider()` is not supported on the native Firebase SDKs.',
         );
       });
     });

Project Files

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
#platform :ios, '10.0'
install! 'cocoapods', :disable_input_output_paths => true
require_relative '../node_modules/react-native-unimodules/cocoapods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'



target 'ReLearn' do

  rnPrefix = "../node_modules/react-native"
  use_native_modules!
  #use_frameworks!
  
  # Download pre-compiled Firestore library.
  #pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.25.0'
  # React Native and its dependencies
  pod 'FBLazyVector', :path => "#{rnPrefix}/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "#{rnPrefix}/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "#{rnPrefix}/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "#{rnPrefix}/Libraries/TypeSafety"
  pod 'React', :path => "#{rnPrefix}/"
  pod 'React-Core', :path => "#{rnPrefix}/"
  pod 'React-CoreModules', :path => "#{rnPrefix}/React/CoreModules"
  pod 'React-RCTActionSheet', :path => "#{rnPrefix}/Libraries/ActionSheetIOS"
  pod 'React-RCTAnimation', :path => "#{rnPrefix}/Libraries/NativeAnimation"
  pod 'React-RCTBlob', :path => "#{rnPrefix}/Libraries/Blob"
  pod 'React-RCTImage', :path => "#{rnPrefix}/Libraries/Image"
  pod 'React-RCTLinking', :path => "#{rnPrefix}/Libraries/LinkingIOS"
  pod 'React-RCTNetwork', :path => "#{rnPrefix}/Libraries/Network"
  pod 'React-RCTSettings', :path => "#{rnPrefix}/Libraries/Settings"
  pod 'React-RCTText', :path => "#{rnPrefix}/Libraries/Text"
  pod 'React-RCTVibration', :path => "#{rnPrefix}/Libraries/Vibration"
  pod 'React-Core/RCTWebSocket', :path => "#{rnPrefix}/"
  pod 'React-Core/DevSupport', :path => "#{rnPrefix}/"
  pod 'React-cxxreact', :path => "#{rnPrefix}/ReactCommon/cxxreact"
  pod 'React-jsi', :path => "#{rnPrefix}/ReactCommon/jsi"
  pod 'React-jsiexecutor', :path => "#{rnPrefix}/ReactCommon/jsiexecutor"
  pod 'React-jsinspector', :path => "#{rnPrefix}/ReactCommon/jsinspector"
  pod 'ReactCommon/jscallinvoker', :path => "#{rnPrefix}/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "#{rnPrefix}/ReactCommon"
  pod 'Yoga', :path => "#{rnPrefix}/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => "#{rnPrefix}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rnPrefix}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rnPrefix}/third-party-podspecs/Folly.podspec"

  # Permission Managers
  permissions_path = '../node_modules/react-native-permissions/ios'

  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec"

  # Other native modules
  #pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  #pod 'RNReanimated', :podspec => '../node_modules/react-native-reanimated/RNReanimated.podspec'
  #pod 'RNScreens', :path => '../node_modules/react-native-screens'
  #pod 'react-native-appearance', :path => '../node_modules/react-native-appearance'


  pod 'react-native-transcript', :path => '../node_modules/react-native-transcript' 

  # Automatically detect installed unimodules
  require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
  use_unimodules!(
    modules_paths: ['../node_modules'],
    exclude: [
      'expo-bluetooth',
      'expo-in-app-purchases',
      'expo-payments-stripe',
    ],
  )
  


end



post_install do |installer|
  

  puts "Renaming logging functions"

  root = File.dirname(installer.pods_project.path)
  Dir.chdir(root);
  Dir.glob("**/*.{h,cc,cpp,in}") {|filename|
    filepath = root + "/" + filename
    text = File.read(filepath)
    addText = text.gsub!(/(?<!React)AddLogSink/, "ReactAddLogSink")
    if addText
      File.chmod(0644, filepath)
      f = File.open(filepath, "w")
      f.write(addText)
      f.close
    end

    text2 = addText ? addText : text
    removeText = text2.gsub!(/(?<!React)RemoveLogSink/, "ReactRemoveLogSink")
    if removeText
      File.chmod(0644, filepath)
      f = File.open(filepath, "w")
      f.write(removeText)
      f.close
    end
  }
  
   
end

AppDelegate.m:

#import <Firebase.h>

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <TSBackgroundFetch/TSBackgroundFetch.h>
#import <RNCPushNotificationIOS.h>
#import <UserNotifications/UserNotifications.h>

#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>

@implementation AppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  [FIRDatabase database].persistenceEnabled = YES;
  // [react-native-background-fetch Setup]
  //    THIS ONE TSBackgroundFetch *fetch = [TSBackgroundFetch sharedInstance];
  // [REQUIRED] Register for usual periodic background refresh events here:
  //    THIS ONE  [fetch registerAppRefreshTask];
  self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"ReLearn" initialProperties:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [super application:application didFinishLaunchingWithOptions:launchOptions];

  return YES;
}

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
  [RNCPushNotificationIOS didReceiveLocalNotification:notification];
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
  // You can inject any extra modules that you would like here, more information at:
  // https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
  return extraModules;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
    OS: macOS 10.15.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
    Memory: 480.98 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    npm: 6.14.4 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
  IDEs:
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  npmPackages:
    react: ~16.9.0 => 16.9.0 
    react-native: ~0.61.4 => 0.61.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • [X ] iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    "@react-native-firebase/app": "^8.2.0",
    "@react-native-firebase/auth": "^8.2.0",
  • Firebase module(s) you're using that has the issue:
    • Auth
  • Are you using TypeScript?
    • N
  • Are you using Expo?
    • Y & 36.0.0


@mikehardy
Copy link
Collaborator

I am not sure OAuth support based on firebase implementation has ever been implemented here
I believe the reason is react-native-oauth exists and you can just send the credential in, which has been sufficient for years (I just looked through all the issues and PRs) indicating this either isn't needed much so it's "sufficient based on interest" or "sufficient because it's better", or at least that's how I'd interpret the lack of traffic about it

#40

There is example code there if using a 3rd party (facebook is used, but you can obviously substitute react-native-oauth) authenticator then binding it with firebase via an auth call with the credential

Maybe this helps?

If you would like the native OAuth provider to work it will probably mean creating the PR to do so, the PR adding apple auth support (merged) and the one attempting new OAuth flow and gamecenter (closed unmerged sadly) might be templates

@andersonaddo andersonaddo added the Service: Authentication Firebase Authentication label Jul 12, 2020
@zaptrem
Copy link
Author

zaptrem commented Jul 12, 2020

react-native-oauth has been abandoned for two years so I'd like to avoid all the hacks that might be needed to make it work. That package also doesn't work with react-native-web (I'd like to switch between Firebase Web SDK and rnfirebase depending on platform). I'd love to help but sadly I don't have remotely enough experience to implement it here. For example, the commit which added Apple Auth seems to me like it would instantly respond with "not supported": mikehardy@c222521. Is there a list of all the other features from the native and web SDKs that aren't supported here to guide people like me who are drop-in-replacing them?

@mikehardy
Copy link
Collaborator

I don't believe there is a list, and I don't believe there is a general stance that anything should be unsupported. I'm actually surprised this one is not supported, as mentioned above it might have just been too niche in combo with react-native-oauth working.

I understand what you are saying from a quick scan of react-native-oauth, luckily it appears there is a vibrant alternative package: https://github.com/FormidableLabs/react-native-app-auth

@zaptrem
Copy link
Author

zaptrem commented Jul 13, 2020

Thanks, my problem is solved. (Though this (bug?) still exists)

@Salakar
Copy link
Member

Salakar commented Jul 14, 2020

FYI; auth is on our roadmap of getting a full API refresh to match the Web SDK and add in any missing APIs, we have started some minor work on this (e.g. #3862) but I can't say for certain when the full refresh will be done

@zaptrem
Copy link
Author

zaptrem commented Jul 16, 2020

Thanks, I'll keep an eye on that.

@stale
Copy link

stale bot commented Aug 15, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Aug 15, 2020
@zaptrem
Copy link
Author

zaptrem commented Aug 15, 2020 via email

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Aug 15, 2020
@stale
Copy link

stale bot commented Sep 12, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Sep 12, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Oct 4, 2020
@AppKidd
Copy link

AppKidd commented Dec 30, 2020

@mikehardy Please could you take a look at this Stack Overflow question? We've authenticated through react-native-app-auth but can't use an OAuthProvider credential as the library responds with an error.

@mikehardy
Copy link
Collaborator

@mikehardy Please could you take a look at this Stack Overflow question?

Okay, I read it

We've authenticated through react-native-app-auth but can't use an OAuthProvider credential as the library responds with an error.

I saw this in the linked stack overflow, is this the error you mention?

When calling the signInWithCredential, it throw an error : [auth/internal-error].

Could be something we could check, except...

  • it's an issue, and all the things we need to check issues are on the issue template (versions etc)
  • plus for internal errors there is usually logging associated (adb logcat or Xcode dev console from running app)
  • if it's an internal error it likely is an upstream issue (assuming you have fully up to date firebase-android-sdk / firebase-ios-sdk so you should use the associated auth quickstart from those repos to verify
  • if you can't verify upstream then seeing an App.js that reproduces it from a repo based on https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh (plus react-native-app-auth I assume) would be most useful

given the above I don't see anything actionable yet, we need more info and demonstration of the problem

@AppKidd
Copy link

AppKidd commented Dec 30, 2020

@mikehardy Thanks very much for the quick reply. Your assumption regarding the error is correct. I'll get a new issue with the template opened with each of those points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Service: Authentication Firebase Authentication Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

5 participants