private String getAccountUri()

in core/src/main/java/com/microsoft/alm/auth/pat/VstsPatAuthenticator.java [259:284]


    private String getAccountUri(final HttpClient authenticatedClient, final String profileId) throws IOException {
        Debug.Assert(authenticatedClient != null, "authenticatedClient is null");
        Debug.Assert(profileId != null, "profileId is null");

        final String accountApiUrlFormat = "https://app.vssps.visualstudio.com/_apis/Accounts?memberid=%s&api-version=1.0";
        final URI accountApiUrl = URI.create(String.format(accountApiUrlFormat, profileId));

        final String vstsAccountUrlFormat = "https://%s.visualstudio.com/";

        logger.debug("Account API URL: {}", accountApiUrl);

        final String content = authenticatedClient.getGetResponseText(accountApiUrl);

        if (content != null) {
            final AccountList accountList = this.objectMapper.readValue(content, AccountList.class);
            if (accountList != null && accountList.value != null) {
                for (final Account account : accountList.value) {
                    if (account.accountStatus != null && account.accountUri != null) {
                        return String.format(vstsAccountUrlFormat, account.accountName);
                    }
                }
            }
        }

        throw new RuntimeException("Could not find any accounts.");
    }