I am trying to add authentication via Auth0 to my app that uses Django Rest Framework for the API backend and swiftUI for the front end. I have successfully connected auth0 to both the backend and frontent (to DRF via this tutorial and to swift via this tutorial). However, I am struggling to connect the two. I want to figure out a way to use Auth0’s universal login page yet still have the user data show up in my Django Rest Framework API. Do you know of a way to do this, or is there a better way to implement this type of user authentication in my app?
Here is the swift code I have been using to create the Universal Login Page. I am wondering if maybe I have to add an API call to DRF once the Auth0 verifies the credentials, but I am not sure.
Button("Login") {
Auth0
.webAuth()
.audience("https://waittimes/api") // the api in auth0
.start { result in
switch result {
case .success(let credentials):
print("Obtained credentials: \(credentials)")
// maybe use access token to send a request to my DRF API??
case .failure(let error):
print("Failed with: \(error)")
}
}
}