0

I'm trying to implement 2 phase authentication for my application using authy authentication. While trying to verify the token generated in authy mobile app m getting UnknownHostException.

package tes.resource;
import com.authy.*;
import com.authy.api.*;
public class SampleAuthenticator {
    AuthyApiClient client=null;
    public void init(){
        String apiKey = "API_KEY";
        String apiUrl = "http://api.authy.com";
        boolean debugMode = true;

        client = new AuthyApiClient(apiKey, apiUrl, debugMode);
    }
    public void register(String userid,String phone){
        Users user=client.getUsers();
        user.createUser(userid,phone, "57");
    }
    public boolean verify(){
        Tokens tokens = client.getTokens();
        Token verification = tokens.verify(27319980, "7983610");
        return verification.isOk();
    }
    public static void main(String[] args){
        SampleAuthenticator objSampleAuthenticator=new SampleAuthenticator();
        objSampleAuthenticator.init();

        System.out.println(objSampleAuthenticator.verify());
    }
}

I have created a application to test whether authy is verifying the user based on the random token generated in authy app.

Any help is appreciated.

philnash
  • 70,667
  • 10
  • 60
  • 88
Saawan
  • 363
  • 6
  • 24

1 Answers1

0

Authy developer evangelist here.

First I would recommend you change your Authy API key, since you seem to have leaked it in this question.

Secondly, the Authy API URL requires HTTPS. My guess is that you need to change

String apiUrl = "http://api.authy.com";

to an HTTPS url:

String apiUrl = "https://api.authy.com";

Let me know if that helps.

philnash
  • 70,667
  • 10
  • 60
  • 88