title: HTTP Request authentication for SPARQL Insert in Virtuoso endpoint
body: <p>I am trying to perform a SPARQL Insert in a Graph that I have loaded in Virtuoso, doing it trough a HTTP Request against the Virtuoso endpoint.</p>
  
  <p>For the HTTP Request I am using <a href="https://github.com/axios/axios" rel="nofollow noreferrer">axios</a>, and I have already made some SPARQL Select queries succesfully, so my problem lays on the Authentication process that I need to do for updating the Graph.</p>
  
  <p>After quite a lot of research, I have seen that Virtuoso has some paths enabled for different authentication proccesses:</p>
  
  <ul>
  <li><code>http://&lt;cname&gt;/sparql-auth</code> (SQL authentication)</li>
  <li><code>http://&lt;cname&gt;/sparql-oauth</code> (OAuth)</li>
  <li><code>http://&lt;cname&gt;/sparql-graph-crud-auth</code> (OAuth CRUD)</li>
  <li><code>https://&lt;cname&gt;/sparql</code> and <code>https://&lt;cname&gt;/sparql-webid</code> (WebID Protocol)</li>
  </ul>
  
  <p>I want to make it as simple as possible, so I have checked the <code>http://&lt;cname&gt;/sparql-auth</code> and I have been able to log in and perform an Insert query succesfully. This means (I guess) that I do not have any permission problems on my user.</p>
  
  <p>When I try to do it through the HTTP Request however, I am not able to authenticate my user properly, I do not know how to specify the username and the password in a correct way.</p>
  
  <p>I have also discovered that Virtuoso has, by default, the <em>Digest Authentication</em> method activated, so I changed it to the <em>Basic Authentication</em> on the <code>/sparql-auth</code> path as it is the easiest method for me. I have done this change using the <code>http://&lt;cname&gt;/conductor</code> of Virtuoso.</p>
  
  <p>And still, I am not able to authenticate myself correctly through the HTTP Get request, receiving the <em>HTTP status code 401 (Unauthorized)</em>.</p>
  
  <p>This is exatly how I make the Request:</p>
  
  <pre><code>axios.get('http://localhost:8890/sparql-auth?query=' + encodeURIComponent(pruebaInsertQuery),{
          auth: {  // This is provided by axios, to perform an HTTP Basic auth
              username: 'myUserName',
              password: 'myPassword'
          },
      })
      .then((response) =&gt; {
          console.log(response);
      })
      .catch((error) =&gt; {
          console.log(error);
      });
  </code></pre>
  
  <p>I have gone through every tutorial and guide that Virtuoso has, but I'm really new in the SPARQL, RDF and Virtuoso world and I still get lost in everything.</p>
  
  <p>Thank you in advance!!</p>
  
  <hr>
  
  <p><em>Question edited due to some of the comments:</em></p>
  
  <p>I have also tried it with a Post Request and nothing changes.</p>
  
  <p>Another way I've tried is using the <code>http://myUserName:myPassword@localhost:8890/sparql-auth</code>format, but I get the exact same response.</p>
  
  <p>I am not sure at all about if I am passing the exact same strings via the <code>axios</code> call and through the <code>/sparql-auth</code> path. Virtuoso may use some encoding that I have not found about, and I am not being able to find any example of an <em>SQL authentication</em> for Virtuoso (the type of authentication I am trying to use), not even for the Digest Authentication method, which is the default method of Virtuoso.</p>
  
  <p>Nothing appears in my Virtuoso.log regarding the HTTP Requests, not even the succesful ones. I will research more about this as it may be because of the configuration that I have.</p>
  
  <p>Thank you for the help!</p>
  
  <hr>
  
  <p><em>Finally found a way for getting the result I want:</em></p>
  
  <p><strong>I have not been able to find a solution to the authentication problem I stated here</strong>, but I still needed to do those inserts, so I have finally <strong>changed completely my approach</strong> and created my own <strong>Java RESTful service</strong> as an intermediary between my application and <em>Virtuoso</em>. </p>
  
  <p>I have found that <em>Virtuoso</em> provides some libraries for <em>Java</em>, and these libraries have helped me connecting to <em>Virtuoso</em> with the appropiate authorization. I also have to say that creating the service was not easy, but it finally worked.</p>
  
  <p>I hope this information helps someone to think on this approach earlier, because it has caused me a big waste of time in my project. As I have said, I have solved my own problem of doing inserts through my application, but the authentication problem is still there, so feel free to add any new comments on this topic.</p>