title: Authorization Credentials sparql
body: <p>I am newbie in sparql queries. I try to send a sparql query from my android device to an     EndPointURI remote server so i can get the results. I want to select all the results that     match with "salmon", as it seems in my code below.<br>
  My issue is in this line: "ResultSet resultSet = qe.execSelect();".<br>
  When i try to take the results i get<br>
  no authentication challenges found at libcore.net.http.httpURLConnectionImpl.get     Authorization Credentials<br>
  and this because myURL wants authentication credentials and i dont know how to send them.<br>
  Any ideas of how can i send username and password succesfully?<br>
  My imports are :    </p>
  
  <pre><code>import com.hp.hpl.jena.query.Query;    
  import com.hp.hpl.jena.query.QueryExecution;    
  import com.hp.hpl.jena.query.QueryExecutionFactory;    
  import com.hp.hpl.jena.query.QueryFactory;    
  import com.hp.hpl.jena.query.ResultSet;    
  import com.hp.hpl.jena.query.Syntax;    
  </code></pre>
  
  <p>the .jars in my libs file are:    </p>
  
  <pre><code>androjena_0.5,    
  arqoid_0.5,    
  icu4j_3_4,   
  iri-0.8,   
  lucenoid_3.0.2,    
  slf4j-android-1.6.1-RC1    
  </code></pre>
  
  <p>and finally my function</p>
  
  <pre><code>public String queryRemoteSparqlEndpoint()    
  {    
        String username="lala";    
        String password="lala";    
        String queryString = "PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; select ?sp"    
         +where {"   
         +"&lt;URL&gt;"    
         +"?sp \"salmon\"."    
         +"}";    
  
       String sparqlEndpointUri = "myURL/sparql";    
  
       Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);   
  
       query.setLimit(10);    
  
         Authenticator.setDefault(new Authenticator() {    
        @Override    
        protected PasswordAuthentication getPasswordAuthentication() {    
            return new PasswordAuthentication(username, password.toCharArray());    
        }    
    });
  
       QueryExecution qe = QueryExecutionFactory.sparqlService(sparqlEndpointUri, query);
  
       ResultSet resultSet = qe.execSelect();       
       while (resultSet.hasNext())    
       {    
         //.....
       }    
       return results.toString();      
  }    
  </code></pre>
  
  <p>Thank you in advance.</p>