Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleSample Code Block
linenumberstrue
    @Test(enabled = true)
    @Parameters({ "appId", "appSecret" })
    public void testGetSpacesAsApp(String appId, String appSecret) throws UnsupportedEncodingException, WWException {
        WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
        assert !client.isAuthenticated();
        client.authenticate();
        assert client.isAuthenticated();

        List<? extends Space> spaces = client.getSpaces();
        assert (spaces.size() > 0);
    } 

Authentication as an application returns an AppToken which is passed to the authenticationResult property of the WWClient. This includes setting the expiry date for authentication. Subsequent calls using the same WWClient object will check whether the expiry date has passed, in which case it will re-authenticate.