- Build a Recipe Web App with Oracle Backend for Firebase
- Build a Recipe iOS App with Oracle Backend for Firebase
- Build a Recipe Android App with Oracle Backend for Firebase
Googleプロバイダを構成する
Web/JavaScriptアプリケーションを認証する
import {
GoogleAuthProvider,
signInWithPopup,
createUserWithEmailAndPassword,
getAuth,
onAuthStateChanged,
signInWithEmailAndPassword,
signOut
} from "fusabase/auth";
el.signInWithGoogleButton.addEventListener("click", () => {
runAction("Signed in with Google.", async () => {
// ── Sign in with Google ─────────
await signInWithPopup(auth, new GoogleAuthProvider());
});
});
iOS/Swiftアプリケーションを認証する
/// Sign in with Google
func signInWithGoogle() async throws {
isLoading = true
errorMessage = nil
defer { isLoading = false }
do {
_ = try await FusabaseAuth.auth().signIn(with: GoogleAuthProvider())
} catch {
errorMessage = error.localizedDescription
throw error
}
}
// MARK: - Actions
private func signInWithGoogle() {
Task {
do {
try await authService.signInWithGoogle()
} catch {
// AuthService surfaces the message via `errorMessage`; nothing else to do.
}
}
}
// Sign In With Google
Button(action: signInWithGoogle) {
HStack {
if authService.isLoading {
ProgressView()
.controlSize(.small)
.padding(.trailing, 4)
}
Text("Sign In with Google")
.fontWeight(.semibold)
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
.disabled(authService.isLoading)
Android/Javaアプリケーションを認証する
/**
* Signs in with Google. The SDK opens a Custom Tab for the OAuth flow, so an
* Activity is required. The result arrives through the auth state listener
* once the browser redirects back to SocialLoginActivity.
*/
public void signInWithGoogle(Activity activity) {
isLoading.setValue(true);
errorMessage.setValue(null);
auth.startActivityForSignInWithProvider(activity, new GoogleAuthProvider(auth))
.addOnSuccessListener(result -> isLoading.postValue(false))
.addOnFailureListener(error -> {
isLoading.postValue(false);
errorMessage.postValue(error.getMessage());
});
}
public void resumePendingSocialLogin() {
Task<AuthResult> pending = auth.getPendingAuthResult();
if (pending == null) {
isLoading.postValue(false);
return;
}
pending.addOnSuccessListener(result -> isLoading.postValue(false))
.addOnFailureListener(error -> {
isLoading.postValue(false);
errorMessage.postValue(error.getMessage());
});
}/* Sign in with Google */
import android.app.Activity;
import com.oracle.mobile.fusabase.auth.GoogleAuthProvider;
import com.oracle.mobile.fusabase.task.Task;
import com.oracle.mobile.fusabase.auth.AuthResult;<string name="auth_button_google">Sign in with Google</string>
<com.google.android.material.button.MaterialButton
android:id="@+id/googleButton"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_sm"
android:text="@string/auth_button_google" />
binding.googleButton.setOnClickListener(v -> {
binding.errorText.setVisibility(View.GONE);
App.get().auth().signInWithGoogle(requireActivity());
});
binding.googleButton.setEnabled(!active);
@Override
public void onResume() {
super.onResume();
App.get().auth().resumePendingSocialLogin();
}
baasmobile581fb7467326f5b9e063020012ac0157
<activity
android:name="com.oracle.mobile.fusabase.auth.SocialLoginActivity"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="baasmobile581fb7467326f5b9e063020012ac0157" />
</intent-filter>
</activity>~/Library/Android/sdk/platform-tools/adb reverse --list
% ~/Library/Android/sdk/platform-tools/adb reverse tcp:8181 tcp:8181
% ~/Library/Android/sdk/platform-tools/adb reverse --list
host-10 tcp:8181 tcp:8181
%




































