💡 Did you know that you can send us information about your clients through our API? If you have not yet generated your access credentials, we will tell you how to do it .
You will need to use the credentials received in your mailbox to obtain a token and use it to operate.
The following java code example shows how to get it:
public class Login {
public static void main(String[] args) throws IOException {
String client_id = "client_id";
String client_secret = "client_secret";
String undecoded_header = client_id + ":" + client_secret;
String authorization_header = Base64.getEncoder().encodeToString(undecoded_header .getBytes());
String user = "api_user";
String password = "api_password";
String parameters = "grant_type=password&username="+user+"&password="+password;
URL url = new URL("http://api.rayapp.io/oauth/token");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization","Basic "+authorization_header);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setDoOutput(true);
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.writeBytes(parameters);
out.flush();
out.close();
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
}
An example of what will end up being sent to the services is:
grant_type=password&username=19sYBKj0gxNoxMljGStPj7kx2cgdJD90dJZZwzNv&password=HiHbs0WXug6XHsylWwJpRelOefiVO7xe47lLhslr
The service response contains the token that must be used:
{
"access_token":<the_token>,
"token_type”:"bearer",
"expires_in":<expire time>,
"scope":"read write",
"jti":<jti>
}
Once you have the token you can start operating with our API, completing the for each of the calls with the concatenation of the fields and separated by spaces. The token is valid for 1 hour , once it expires you must repeat the login to obtain a new one. header
Authorization
token_type
access_token
The next step is that every time a customer interacts with your business, you call us to notify us of these news:
Visit our Help Center , there you will find more information to continue learning about the platform.
What do you think of this article? 👇