I'm trying to use sign in with Facebook. Not having much luck. I've double-triple checked bundle IDs, app IDs, and redirect urls. I'm not sure what I'm doing wrong? Hopefully someone can provide some insight 🙏
New users are being created in AppWrite, but this error doesn't seem to go away no matter what I've tried. In addition, I think I may be missing the part where I'm supposed to redirect my users back to my app.
Please forgive me as I am new to SwiftUI (not Swift)
//
// AppwriteViewModel.swift
// FacebookGame
//
// Created by Landon Hughes on 7/22/23.
//
import Foundation
import Appwrite
import AppwriteModels
class AppwriteViewModel {
let client: Client
let account: Account
init() {
client = Client()
.setEndpoint("https://cloud.appwrite.io/v1")
.setProject("64bbfb9db0f6820db5ac")
.setSelfSigned()
account = Account(client)
}
func signIntoFacebook() {
do {
let success = try account.createOAuth2Session(provider: "facebook", success: "https://cloud.appwrite.io", scopes: ["public_profile", "user_friends", "email"])
print("SUCCESS: \(String(describing: success))")
} catch {
print("Sign in error: \(error.localizedDescription)")
}
}
}
//
// ContentView.swift
// FacebookGame
//
// Created by Landon Hughes on 7/22/23.
//
import SwiftUI
import Appwrite
struct ContentView: View {
let viewModel = AppwriteViewModel()
var body: some View {
Button("Login") {
viewModel.signIntoFacebook()
}
.registerOAuthHandler()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Don't pass anything for success
Ok. That fixes the issue of bringing the user back into my app. Thank you!
Next issue would be the OpenActionURL error
@Jake Any ideas?
For what it's worth, I think there might be something wrong with my redirect url?
// let viewModel = AppwriteViewModel()
@StateObject var viewModel = AppwriteViewModel()
AppwriteViewModel
should be an ObservableObject
class AppwriteViewModel: ObservableObject {
...
}
Hmm
I see, the users register correctly, but then they are not redirected to the application?
They are redirected back to the app.
It's just that darn OpenActionURL swiftui "bug"
Let me check the SDK code 🤔
Recommended threads
- Error: User (role: guests) missing scope...
I want to send a verification code to the user and the given phone number and check it and create a session right after the user entered the secret. For me that...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...