I need to use API, but Artifactory tells me that I need to be authorized.
I'm using java with Jersey libraries to make REST call:
public class BackupTest {
private static final String USER = "max";
private static final String AUTH_TOKEN = "1111";
private static final String PREFIX = "artifactory";
private static final String GET_REPOSITORIES = PREFIX +
"/api/repositories";
private static final String HOST = "http://" + USER + ":" + AUTH_TOKEN +
"@localhost:8080";
public static void main(String[] args) throws Exception {
JSONArray repositoryList = (JSONArray)getResponse(GET_REPOSITORIES);
System.out.println(repositoryList);
}
private static Object getResponse(String path) throws Exception {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(HOST).path(path);
Invocation.Builder request = target.request();
request.accept(MediaType.APPLICATION_JSON);
Response response = request.get();
if (response.getStatusInfo().getFamily() ==
Response.Status.Family.SUCCESSFUL) {
return new
JSONParser().parse(response.readEntity(String.class));
}
return null;
}
}
This code works, but if I go Admin->General and click on "Hide Existence of
Unauthorized Resources" This code doesn't work and says that I need to be
authorized.
In Artifactory documentation nothing about ho to login to use API.
So, how should I login?
--
View this message in context:
http://forums.jfrog.org/How-to-login-to-Artifactory-to-use-API-tp7580424.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users