Created
October 11, 2022 16:27
-
-
Save viveknaskar/f9bc70f6d357a2271755faed63bffeff to your computer and use it in GitHub Desktop.
Configuration for using Twilio SDK for SMS Alert System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twilio.Twilio; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.context.annotation.Configuration; | |
import javax.annotation.PostConstruct; | |
@Configuration | |
public class TwilioConfig { | |
@Value("${twilio.account.sid}") | |
private String twilioAccountSid; | |
@Value("${twilio.auth.token}") | |
private String twilioAuthToken; | |
/** | |
* The credentials Account SID and Auth Token from the Twilio Console should be | |
* there in the environment, hence the @PostConstruct init() ensures that the credentials | |
* are there in application context. | |
*/ | |
@PostConstruct | |
public void init() { | |
Twilio.init( | |
getTwilioAccountSid(), | |
getTwilioAuthToken() | |
); | |
} | |
public String getTwilioAccountSid() { | |
return twilioAccountSid; | |
} | |
public String getTwilioAuthToken() { | |
return twilioAuthToken; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment