twilio / authy-ruby

**Deprecated** Ruby library to access the authy API
MIT License
156 stars 47 forks source link

Can't Receive SMS in production Heroku #46

Closed mr3abd closed 5 years ago

mr3abd commented 5 years ago

Hello,

I know when test Sent SMS in Heroku here Post user data(Phone and country code) here msayefdev.herokuapp.com/api/v1/host/sign_up can't receive SMS but working in localhost:3000

that my code

def create

 host = Host.new(host_paramssignin)

   if host&.save
     @response = Authy::PhoneVerification.start(
       via: params[:sms],
       country_code: host.country_code,
       phone_number: host.phone_number
     )

      render :json=> host.as_json(:auth_token=>host.authentication_token, :phone_number => host.phone_number ), :status=>201
      return

    else

  warden.custom_failure!

   render :json => host.errors, :status=>422

   end
 end

Can help me ?

philnash commented 5 years ago

Do you get an error message in your Heroku logs? What is the result of Authy::PhoneVerification.start that you store as @response?

Do you have your Authy API key saved correctly in your environment variables in Heroku?

mr3abd commented 5 years ago

When reviewing my code I get the issue Haven't API in environment variables in Heroku how to call API in production ?

philnash commented 5 years ago

Do you have an authy.rb file in config/initializers/? Does it have something like:

Authy.api_key = ENV["AUTHY_API_KEY"]

If so, you need to set your Authy API key in the Heroku environment. To do so, run the following in your application directory:

heroku config:set AUTHY_API_KEY=YOUR_AUTH_API_KEY

Make sure you use your own Authy API key in the above.

Let me know if that helps.

mr3abd commented 5 years ago

So nice!

it's worked ^^

philnash commented 5 years ago

That's great to hear! Good luck with the rest of your app!