Skip to content

Instantly share code, notes, and snippets.

@viveknaskar
Created October 11, 2022 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viveknaskar/f9bc70f6d357a2271755faed63bffeff to your computer and use it in GitHub Desktop.
Save viveknaskar/f9bc70f6d357a2271755faed63bffeff to your computer and use it in GitHub Desktop.
Configuration for using Twilio SDK for SMS Alert System
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