LzMingYueShanPao opened a new issue, #1919:
URL: https://github.com/apache/incubator-hugegraph/issues/1919

   ### Problem Type (问题类型)
   
   other exception / error (其他异常报错)
   
   ### Before submit
   
   - [X] 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 
[FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题
   
   ### Environment (环境信息)
   
   图名称:meta_hugegraph
   本地HTTP地址端口:192.168.66.83:8080
   版本:HugeGraph   0.11.2
   
   ### Your Question (问题描述)
   
   
使用StandardAuthenticator模式开启权限认证后,使用默认的admin账号和空串密码发送Http请求,访问HugeGraph一些查询接口,出现{"exception":"class
 javax.ws.rs.NotAuthorizedException","message":"Authentication failed for user 
'admin'","cause":""}。
   使用的Java示例代码如下:
   import org.apache.commons.net.util.Base64;
   import org.apache.http.HttpHeaders;
   import org.apache.http.HttpResponse;
   import org.apache.http.client.HttpClient;
   import org.apache.http.client.methods.HttpGet;
   import org.apache.http.impl.client.HttpClientBuilder;
   import org.apache.http.util.EntityUtils;
   import java.nio.charset.StandardCharsets;
   
   public class GetHttp {
   
       public static void main(String[] args) throws Exception {
           String url = 
"http://192.168.66.83:8080/graphs/meta_hugegraph/schema/vertexlabels";;
           String user = "admin";
           String password = "";
   
           HttpGet request = new HttpGet(url);
           // 手动构建验证信息
           String auth = "Basic base64(" + user + ":" + password + ")";
           byte[] encodedAuth = Base64.encodeBase64(
                   auth.getBytes(StandardCharsets.UTF_8));
           String authHeader = new String(encodedAuth);
           System.out.println(authHeader);
           // 将验证信息放入到 Header
           request.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
           HttpClient client = HttpClientBuilder.create().build();
           HttpResponse response = client.execute(request);
           int statusCode = response.getStatusLine().getStatusCode();
           System.out.println(statusCode);
           String s = EntityUtils.toString(response.getEntity(), 
StandardCharsets.UTF_8);
           System.out.println(s);
       }
   }
   
   ### Vertex/Edge example (问题点 / 边数据举例)
   
   ```javascript
   无
   ```
   
   
   ### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
   
   ```javascript
   无
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to