Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-2821

Realm app fails to authenticate users when running on Android emulator

      How frequently does the bug occur?

      Always

      Description

      Hi all,

      I'm unable to authenticate the realm user when I'm running my app on an Android Emulator. I keep getting the following errors;

       ERROR  [Realm.App - error] App: request location failed (CustomError -1): request to https://services.cloud.mongodb.com/api/client/v2.0/app/application-0-xxxxxx/location failed, reason: Network request failed      
       ERROR  [Realm.App - error] App: log_in_with_credentials failed: 0 message: request to https://services.cloud.mongodb.com/api/client/v2.0/app/application-0-xxxxxx/location failed, reason: Network request failed 
      

      The authentication works when I use a physical device, but fails instantly when I run on an Emulator. I'm using the customJWT auth flow shown below;

      const LogInScreen = () => {
      
        const {logInWithJWT, result} = useAuth();
        //const {logInWithAnonymous, result} = useAuth();
      
        const login = React.useCallback(async () => {
          try {
            var tokens = await SignInAzure();
            logInWithJWT(tokens["id_token"]);
          } catch (error) {
            console.log(error);
          }
        });
      
        return (
          <View>
            <Button title="Sign in to realm" onPress={login} />
          </View>
        );
      };
      

      LoginScreen is passed to my UserProvider like so;

      {{<UserProvider fallback=

      {<LogInScreen />}>}}

      I've tried anonymous auth and email password authentication, both of which fail on emulator but succeed on a physical device.

      h3. Stacktrace & log output
      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      ERROR  [Realm.App - error] App: request location failed (CustomError -1): request to https://services.cloud.mongodb.com/api/client/v2.0/app/application-0-xxxxxx/location failed, reason: Network request failed      
       ERROR  [Realm.App - error] App: log_in_with_credentials failed: 0 message: request to https://services.cloud.mongodb.com/api/client/v2.0/app/application-0-xxxxxx/location failed, reason: Network request failed
      

      h3. Can you reproduce the bug?
      Always

      h3. Reproduction Steps
      React Version 0.73.1
      @realm/react

      * 0.7.0
      realm: 12.9.0

      Using a Pixel 5 emulator running platform version 34
      
      

      <AppProvider id={Config.REALM_APP_ID}>
      <UserProvider fallback={<LogInScreen />}

      >
      <RealmProvider
      sync={{
      flexible: true,
      initialSubscriptions: {
      update(subs, realm)

      { subs.add(realm.objects(TemplateOpportunity)); }

      ,
      },
      }}
      >
      <GestureHandlerRootView>
      <NavigationContainer>
      <Tabs />
      </NavigationContainer>
      </GestureHandlerRootView>
      </RealmProvider>
      </UserProvider>
      </AppProvider>

      
      

      Version

      12.9.0

      What services are you using?

      Atlas Device Sync

      Are you using encryption?

      Yes

      Platform OS and version(s)

      Android SDK Version 34 & 33

      Build environment

      Which debugger for React Native: ..

      Cocoapods version

      No response

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: