简体   繁体   English

身份验证 Azure Java SDK

[英]Authentication Azure Java SDK

I am using 1.0.0-beta4.1 Azure Java SDK.我使用的是 1.0.0-beta4.1 Azure Java SDK。 This is my code for authentication这是我的身份验证代码

    // TODO Auto-generated method stub
    String client = "xxxxxxxxxxx";
    String tenant = "xxxxxxxxxxx";
    String key = "xxxxxxxxxxx";
    String subscriptionId = "xxxxxxxxxxx";

    ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(client, tenant, key, AzureEnvironment.AZURE);
    Azure azure = Azure.authenticate(credentials).withSubscription(subscriptionId);
    System.out.println("Listing all resource groups");

The code doesn't throw any error in case of incorrect credentials.如果凭据不正确,代码不会引发任何错误。 Is there any way to find whether the authentication was successful or not.有什么办法可以查到认证是否成功。

According to your code, it seems that missing some required methods which include configure() , please see below.根据您的代码,似乎缺少一些必需的方法,包括configure() ,请参见下文。

Azure azure = Azure.configure()  // Initial an Azure.Configurable object
                   .withLogLevel(HttpLoggingInterceptor.Level.BASIC)
                   .authenticate(credentials)
                   .withSubscription(subscriptionId);

Please try to use the code above instead of yours.请尝试使用上面的代码而不是您的代码。 Any update, please feel free to let me know.任何更新,请随时让我知道。

I just got the same exception and I was able to resolve it by replacing HttpLoggingInterceptor.Level.BASIC with LogLevel.BASIC.我刚刚得到了同样的异常,我能够LogLevel.BASIC更换HttpLoggingInterceptor.Level.BASIC来解决它。

Aso, I would like to inform that I used the dependency Aso,我想通知我使用了依赖项

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.0.0</version>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM