How to generate a valid email verifcation link from the codebase instead of using Auth0 actions

Ready to post? :mag: First, try searching for your answer.
Hi Folks, I am currently facing an issue where I am trying to generate a valid email verification link using Auth0 management Api and send from my rails codebase

Here is the code that I am using

require ‘net/http’
require ‘json’
require ‘uri’

class Auth0Service
AUTH0_DOMAIN = ‘YOUR_AUTH0_DOMAIN’.freeze
MANAGEMENT_API_TOKEN = ‘YOUR_MANAGEMENT_API_TOKEN’.freeze

def initialize(user_id)
@user_id = user_id
end

def send_verification_email
uri = URI(“https://#{AUTH0_DOMAIN}/api/v2/jobs/verification-email”)

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{MANAGEMENT_API_TOKEN}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({ user_id: @user_id })

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

case response
when Net::HTTPSuccess
  JSON.parse(response.body) # You can adjust this if needed
else
  raise "Failed to send verification email: #{response.body}"
end

end
end

But problem is I am not seeing any error to debug this. If anyone has faced similar issue please help me out

Hi @ayushsrivastava

Welcome to the Auth0 Community!

Thank you for posting your question. Based on our documentation regarding sending verification emails, please try updating your code with client_id in the request.Body

Thanks
Dawid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.