The app I am building requires passwordless authentication and allows users to create new accounts. I am using Twilio Verify for phone/email verification and all is well. I create a new directus_users row. Fine. Now I am trying to figure out how to create a session for that new user programatically from within my endpoint extension and I am not having success. So close! I can’t call the login method of the AuthService since it requires email and password. Any ideas how I can get a real directus session started and what I should return to the frontend so the frontend can use the GraphQL or REST API as the newly authenticated user?
Hello @sam0,
Since you don’t have the user’s email and password, you can still create an access token using just the user_id.
Check out the login logic in the AuthenticationService (see this code). You can use a similar approach, but instead of requiring an email and password, you can issue the token based on the user_id. This way, you’ll generate the access token and return it to the frontend for use in GraphQL or REST API requests.
Hope this clears things up