otp verification in spring boot

Solutions on MaxInterview for otp verification in spring boot by the best coders in the world

showing results for - "otp verification in spring boot"
Marlene
04 Jul 2019
1//Your authentication key
2
3	String authkey = "YourAuthKey";
4
5	//Mobile number to which OTP needs to be sent
6	String mobiles = "+91XXXXXXXXXX";
7
8	//Your otp value to be sent.
9	String otpValue = "12345";
10
11	URLConnection myURLConnection=null;
12	URL myURL=null;
13	BufferedReader reader=null;
14
15	//encoding message
16	//Send SMS API
17	String mainUrl="https://2factor.in/API/V1/"+authkey+"/SMS/"+mobiles+"/"+otpValue;
18
19	//Prepare parameter string
20	StringBuilder sbPostData= new StringBuilder(mainUrl);
21	sbPostData.append("1=1");
22	//final string
23	mainUrl = sbPostData.toString();
24	try
25	{
26	    //prepare connection
27	    myURL = new URL(mainUrl);
28	    myURLConnection = myURL.openConnection();
29	    myURLConnection.connect();
30	    reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
31
32	    //reading response
33	    String response;
34	    while ((response = reader.readLine()) != null)
35	    //print response
36	    Log.d("RESPONSE", ""+response);
37
38	    //finally close connection
39	    reader.close();
40	}
41	catch (IOException e)
42	{
43	e.printStackTrace();
44
45	}
46