Ready to post? 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