@Override public Token generatePersonalAccessToken(final URI targetUri,final Token accessToken,final VsoTokenScope tokenScope,final boolean requireCompactToken){
  Debug.Assert(targetUri != null,"The targetUri parameter is null");
  Debug.Assert(accessToken != null && !StringHelper.isNullOrWhiteSpace(accessToken.Value) && (accessToken.Type == TokenType.Access || accessToken.Type == TokenType.Federated),"The accessToken parameter is null or invalid");
  Debug.Assert(tokenScope != null,"The tokenScope parameter is invalid");
  Trace.writeLine("VsoAzureAuthority::generatePersonalAccessToken");
  try {
    final HttpClient client=new HttpClient(Global.getUserAgent());
    Trace.writeLine("   using token to acquire personal access token");
    accessToken.contributeHeader(client.Headers);
    if (populateTokenTargetId(targetUri,accessToken)) {
      final URI requestUrl=createPersonalAccessTokenRequestUri(client,targetUri,requireCompactToken);
      final StringContent content=getAccessTokenRequestBody(targetUri,accessToken,tokenScope);
      final HttpURLConnection response=client.post(requestUrl,content);
      if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
        final String responseText=HttpClient.readToString(response);
        final Token token=parsePersonalAccessTokenFromJson(responseText);
        if (token != null) {
          Trace.writeLine("   personal access token acquisition succeeded.");
        }
        return token;
      }
    }
  }
 catch (  final IOException e) {
    throw new Error(e);
  }
  return null;
}

@ Override public Token generatePersonalAccessToken ( final URI targetUri , final Token accessToken , final VsoTokenScope tokenScope , final boolean requireCompactToken ) { Debug . Assert ( targetUri != null , "The targetUri parameter is null" ) ; Debug . Assert ( accessToken != null && ! StringHelper . isNullOrWhiteSpace ( accessToken . Value ) && ( accessToken . Type == TokenType . Access || accessToken . Type == TokenType . Federated ) , "The accessToken parameter is null or invalid" ) ; Debug . Assert ( tokenScope != null , "The tokenScope parameter is invalid" ) ; Trace . writeLine ( "VsoAzureAuthority::generatePersonalAccessToken" ) ; try { final HttpClient client = new HttpClient ( Global . getUserAgent ( ) ) ; Trace . writeLine ( "   using token to acquire personal access token" ) ; accessToken . contributeHeader ( client . Headers ) ; if ( populateTokenTargetId ( targetUri , accessToken ) ) { final URI requestUrl = createPersonalAccessTokenRequestUri ( client , targetUri , requireCompactToken ) ; final StringContent content = getAccessTokenRequestBody ( targetUri , accessToken , tokenScope ) ; final HttpURLConnection response = client . post ( requestUrl , content ) ; if ( response . getResponseCode ( ) == HttpURLConnection . HTTP_OK ) { final String responseText = HttpClient . readToString ( response ) ; final Token token = parsePersonalAccessTokenFromJson ( responseText ) ; if ( token != null ) { Trace . writeLine ( "   personal access token acquisition succeeded." ) ; } return token ; } } } catch ( final IOException e ) { throw new Error ( e ) ; } return null ; }
generates a personal access token for use with visual studio online .
