Session expired every time program runs

sourav359
sourav359 edited April 2020 in Java client
My problem is that every time I am running the program it is asking fro login. I read that to bypass it (within 24hrs) we can use AccessToken instead of RequestToken. But I am unable to set it. How and where to set it. Please help.

Here is my code -
-------------------------------------------
User userModel = connection.generateSession("Request Token", "Secret API");

System.out.println(userModel.accessToken);
System.out.println(userModel.publicToken);

connection.setAccessToken(userModel.accessToken);
connection.setPublicToken(userModel.publicToken);

Example ex = new Example ();
ex.getProfile(connection);
This discussion has been closed.