Skip to content

Commit

Permalink
[FIX] change to use key value
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Mar 8, 2024
1 parent 411cc3f commit 007eafc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.twtw.backend.config.firebase;

import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
Expand All @@ -9,9 +10,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

@Slf4j
@Configuration
Expand All @@ -21,10 +19,9 @@ public class FcmConfig {
private final FirebaseProperties firebaseProperties;

@Bean
public FirebaseApp firebaseApp() throws IOException {
public FirebaseApp firebaseApp() {
final FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(
new ClassPathResource(firebaseProperties.getLocation()).getInputStream()))
.setCredentials(GoogleCredentials.create(new AccessToken(firebaseProperties.getKey(), null)))
.build();

if (FirebaseApp.getApps().isEmpty()) {
Expand All @@ -34,7 +31,7 @@ public FirebaseApp firebaseApp() throws IOException {
}

@Bean
public FirebaseMessaging firebaseMessaging() throws IOException {
public FirebaseMessaging firebaseMessaging() {
return FirebaseMessaging.getInstance(firebaseApp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@RequiredArgsConstructor
@ConfigurationProperties(prefix = "firebase")
public class FirebaseProperties {
private final String location;
private final String key;
}

0 comments on commit 007eafc

Please sign in to comment.