firebase-admin-java
firebase-admin-java copied to clipboard
Unknown error while making a remote service call: Unexpected error refreshing access token
[REQUIRED] Step 2: Describe your environment
- Operating System version: Windows 10
- Firebase SDK version: 8.1.0
- Library version: _____
- Firebase Product: auth
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
I wanted to get registered users of FIrebase to my Spring application so I initialized firebase app as shown here
@Service
@Slf4j
public class MSFirebaseInitializer
{
@Value("${FIREBASE_SERVICE_CONFIG_KEY}")
private String firebaseConfigPath;
@SneakyThrows
@PostConstruct
public void initialize() throws IOException
{
try
{
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials( GoogleCredentials.fromStream( new FileInputStream( firebaseConfigPath ) ) )
.build();
if ( FirebaseApp.getApps().isEmpty() )
{
FirebaseApp.initializeApp( options );
log.info( "Firebase application has been initialized" );
}
}
catch ( IOException e )
{
log.error( e.getMessage() );
}
}
}
I wrote two tests as down bellow
@RunWith(SpringRunner.class)
@SpringBootTest
public class MSFirebaseTest
{
@Autowired
MSFirebaseInitializer firebaseInitializer;
@Test
public void firebaseAppInitializationTest() throws IOException, FirebaseAuthException
{
firebaseInitializer.initialize();
System.out.println(FirebaseApp.getApps());
assertFalse(FirebaseApp.getApps().isEmpty());
}
@Test
public void connect_dev(){
UserRecord userRecord = null;
try
{
userRecord= FirebaseAuth.getInstance(FirebaseApp.getInstance()).getUserByPhoneNumber( "+9xxx" );
}
catch ( FirebaseAuthException e)
{
e.printStackTrace();
}
assertEquals( userRecord.getPhoneNumber(),"+9xxx" );
}
//
}
First test get pass and in the second test I'm getting AuthException
com.google.firebase.auth.FirebaseAuthException: Unknown error while making a remote service call: Unexpected error refreshing access token
at com.google.firebase.auth.internal.AuthErrorHandler.createException(AuthErrorHandler.java:122)
at com.google.firebase.auth.internal.AuthErrorHandler.createException(AuthErrorHandler.java:35)
at com.google.firebase.internal.AbstractHttpErrorHandler.handleIOException(AbstractHttpErrorHandler.java:63)
at com.google.firebase.internal.ErrorHandlingHttpClient.createHttpRequest(ErrorHandlingHttpClient.java:141)
at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:92)
at com.google.firebase.auth.internal.AuthHttpClient.sendRequest(AuthHttpClient.java:75)
at com.google.firebase.auth.FirebaseUserManager.lookupUserAccount(FirebaseUserManager.java:238)
at com.google.firebase.auth.FirebaseUserManager.getUserByPhoneNumber(FirebaseUserManager.java:133)
at com.google.firebase.auth.AbstractFirebaseAuth$8.execute(AbstractFirebaseAuth.java:557)
at com.google.firebase.auth.AbstractFirebaseAuth$8.execute(AbstractFirebaseAuth.java:554)
at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
at com.google.firebase.auth.AbstractFirebaseAuth.getUserByPhoneNumber(AbstractFirebaseAuth.java:534)
Can anyone help me. What I'm doing wrong?
P.S. I got ErrorCode
as UNKNOWN
Hi @bawantha do you still have this issue? If so please provide a minimal repro so we can investigate. Thanks!
Closing due to inactivity.