auth0 / Auth0.swift

Auth0 SDK for Apple platforms
https://auth0.github.io/Auth0.swift
MIT License
345 stars 225 forks source link

Login with OTP with custom realm #805

Closed MarvinNazari closed 10 months ago

MarvinNazari commented 10 months ago

Checklist

Describe the problem you'd like to have solved

We have a scenario in our app that needs to login with email and code to verify the email with a custom realm, in Authentication right now realm is hardcoded to always be email, we need to specify our own realm in this case email-verify.

Describe the ideal solution

We should be able to specify our own realm in this case email-verify for when login when using Authentication. there is already a internal function that could be exposed.

func login(username: String, otp: String, realm: String, audience: String?, scope: String) -> Request<Credentials, AuthenticationError>

Alternatives and current workarounds

For workaround we are now just calling the endpoints ourselves.

Additional context

No response

Widcket commented 10 months ago

Hi @MarvinNazari, apologies for the delay.

All the methods of the Authentication API client return a Request value, and this type has a parameters() method that can be used to add new values to the request payload, or to modify the existing ones.

You can use it to pass your own realm value, e.g.

Auth0
    .authentication()
    .login(email: "...", code: "...", audience: "...", scope: "...")
    .parameters(["realm": "email-verify"])
    .start { print($0) }