authy-java icon indicating copy to clipboard operation
authy-java copied to clipboard

NullPointerException in version 1.2.0 (com.authy.api.Resource.java)

Open tpthaler opened this issue 9 years ago • 1 comments

` StringBuilder e = new StringBuilder(); if(method.equals("GET")) { e.append(this.prepareGet(data)); }

        URL url = new URL(this.apiUri + path + e.toString());
        HttpURLConnection connection = this.createConnection(url, method, options);
        connection.setRequestProperty("X-Authy-API-Key", this.apiKey);
        if(data.toMap().containsKey("api_key")) {//THROWS A NULL POINTER EXCEPTION
            LOGGER.log(Level.WARNING, "Found \'api_key\' as a parameter, please remove it, Authy-Java already handles the\'api_key\' for you.");
        }

        if(method.equals("POST") || method.equals("PUT")) {
            if(this.isJSON) {
                this.writeJson(connection, data);
            } else {
                this.writeXml(connection, data);
            }
        }

        this.status = connection.getResponseCode();
        answer = this.getResponse(connection);
    } catch (SSLHandshakeException var9) {
        System.err.println("SSL verification is failing. This might be because of an attack. Contact [email protected]");
    } catch (Exception var10) {
        var10.printStackTrace();
    }

    return answer;
}

`

This line of code is throwing a NPE when trying to create a user, using your documented process (the createUser line below works fine in version 1.1.0):

` User user = users.createUser("[email protected]", "405-342-5699", "57");

//eventually calls this which is what blows up as data = null if(data.toMap().containsKey("api_key")) { `

tpthaler avatar May 20 '17 20:05 tpthaler

@tpthaler looks like it is working now

vargasx avatar May 23 '17 16:05 vargasx