For Reference: I'm trying to use this library: https://github.com/danshannon/javastravav3api
For an API OAuth token, the library has no function to store the token perpetually. I tried to just make a class that extends Token and makes it implement Serialization to have perpetual tokens, but whenever I read the token all the fields are null. I checked to make sure the fields are not null right before writing the objects.
public class SerialToken extends Token implements Serializable
{
    public SerialToken() {
    }
    public SerialToken(TokenResponse tokenResponse, AuthorisationScope... scopes) {
        super(tokenResponse, scopes);
    }
}
public class Main {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
    // write your code here
        File f = new File("lastToken.txt");
        SerialToken token;
        if (!f.exists()) {
            AuthorisationAPI auth = API.authorisationInstance();
            TokenResponse response = auth.tokenExchange(/*credentials*/);
            token = new SerialToken(response);
            //System.out.println(token.getAthlete().getCity()); used to double check object isnt null going in (which it isnt)
            FileOutputStream fos = new FileOutputStream(f);
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(token);
        }
        else
        {
            FileInputStream fis = new FileInputStream(f);
            ObjectInputStream ois = new ObjectInputStream(fis);
            token = (SerialToken) ois.readObject();
        }
        System.out.println(token.getAthlete().getCity());
      
    }
}
Once I run it the first time to initialize my tokens it works perfectly, but whenever I run it a second time I get a null pointer exception from token.getAthlete(), where the token is not null but all its attributes (including the Athelete attribute) are null.
Thanks!
 
     
     
    