本文整理汇总了Java中com.google.firebase.auth.FirebaseCredentials类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseCredentials类的具体用法?Java FirebaseCredentials怎么用?Java FirebaseCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseCredentials类属于com.google.firebase.auth包,在下文中一共展示了FirebaseCredentials类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createOptionsWithFirebaseCredential
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
@Test
public void createOptionsWithFirebaseCredential() throws IOException {
FirebaseOptions firebaseOptions =
new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(ServiceAccount.EDITOR.asStream()))
.build();
assertNotNull(firebaseOptions.getJsonFactory());
assertNotNull(firebaseOptions.getHttpTransport());
assertNull(firebaseOptions.getDatabaseUrl());
assertNull(firebaseOptions.getStorageBucket());
GoogleCredentials credentials = firebaseOptions.getCredentials();
assertNotNull(credentials);
assertTrue(credentials instanceof ServiceAccountCredentials);
assertEquals(
GoogleCredential.fromStream(ServiceAccount.EDITOR.asStream()).getServiceAccountId(),
((ServiceAccountCredentials) credentials).getClientEmail());
}
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:20,代码来源:FirebaseOptionsTest.java
示例2: initFirebase
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
/**
* Inicializace firebase služby
*/
private void initFirebase() {
try {
InputStream serviceAccount = getClass().getResourceAsStream(FIREBASE_CREDENTAILS);
Map<String, Object> auth = new HashMap<>();
auth.put("uid", "my_resources");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl(FIREBASE_URL)
.setDatabaseAuthVariableOverride(auth)
.build();
FirebaseApp.initializeApp(options);
} catch (Exception e) {
logger.info("Nemůžu se připojit k firebase", e);
}
}
开发者ID:stechy1,项目名称:drd,代码行数:22,代码来源:Context.java
示例3: firebaseApp
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
@Provides
@Singleton
static FirebaseApp firebaseApp(FirebaseAuthConfig config) {
final FirebaseOptions options;
try {
options =
new FirebaseOptions.Builder()
.setCredential(
FirebaseCredentials.fromCertificate(
new ByteArrayInputStream(
Base64.getDecoder().decode(config.getServiceAccountBase64()))))
.setDatabaseUrl("https://" + config.getProjectId() + ".firebaseio.com")
.build();
} catch (IOException e) {
throw new UncheckedIOException("Could not read certificate.", e);
}
FirebaseApp.initializeApp(options);
return FirebaseApp.getInstance();
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:20,代码来源:FirebaseAuthModule.java
示例4: initializeFirebase
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
/**
* Initialize firebase.
*
* @param pathConfig the path config
* @param atribute the atribute
* @param pathdefault the pathdefault
* @return the firebase auth
*/
private static void initializeFirebase(String pathConfig, String atribute, String pathdefault) {
try {
File config = new File(pathConfig + properties.getProperty(atribute));
InputStream serviceAccount;
if (config.exists()) {
serviceAccount = new FileInputStream(config);
logger.info("initializeFirebase outside" + config);
} else {
serviceAccount = FileUtils.getFile(pathdefault);
logger.info("initializeFirebase inside" + pathdefault);
}
// Initialize Firebase
FirebaseOptions options = new FirebaseOptions.Builder().setCredential(FirebaseCredentials.fromCertificate(serviceAccount)).build();
FirebaseApp.initializeApp(options, "members");
serviceAccount.close();
} catch (Exception e) {
logger.error("initializeFirebase ", e);
}
}
开发者ID:pablogrela,项目名称:members_cuacfm,代码行数:28,代码来源:ApplicationConfig.java
示例5: getCreds
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
private FirebaseCredential getCreds(String credsPath) throws IOException {
if (StringUtils.isNotBlank(credsPath)) {
return FirebaseCredentials.fromCertificate(new FileInputStream(credsPath));
} else {
return FirebaseCredentials.applicationDefault();
}
}
开发者ID:kamax-io,项目名称:mxisd,代码行数:8,代码来源:GoogleFirebaseBackend.java
示例6: initialize
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
private FirebaseApp initialize() {
try (FileInputStream serviceAccount = new FileInputStream(getServiceAccountFilePath())) {
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl(databaseUrl)
.build();
return FirebaseApp.initializeApp(options);
} catch (IOException e) {
System.out.println(e.getMessage());
return null;
}
}
开发者ID:trvlrch,项目名称:trvlr-backend,代码行数:14,代码来源:FirebaseService.java
示例7: initFirebase
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
public void initFirebase(String databaseUrl, InputStream serviceAccount) {
FirebaseOptions options =
new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl(databaseUrl)
.build();
if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp(options);
}
}
开发者ID:google,项目名称:iosched,代码行数:12,代码来源:FirebaseWrapper.java
示例8: getAccessToken
import com.google.firebase.auth.FirebaseCredentials; //导入依赖的package包/类
public String getAccessToken(InputStream serviceAccount) {
Task<String> tokenTask = FirebaseCredentials.fromCertificate(serviceAccount)
.getAccessToken(false);
try {
Tasks.await(tokenTask);
} catch (InterruptedException | ExecutionException e) {
LOG.log(Level.SEVERE, "An error occurred while generating the access token", e);
return null;
}
return tokenTask.getResult();
}
开发者ID:google,项目名称:iosched,代码行数:12,代码来源:FirebaseWrapper.java
注:本文中的com.google.firebase.auth.FirebaseCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论