azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

ERROR c.a.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://vault.azure.net/.default]: clientSecret is null or empty

Open Aranipavan123 opened this issue 1 year ago • 5 comments

This is the methoud i am using to create datasource private DataSource createDataSourceForTenant(String realmID) { try { // Construct secret IDs String passwordSecretId = String.format(PASSWORD_SECRET_NAME_FORMAT, environment, realmID); String serverSecretId = String.format(SERVER_SECRET_NAME_FORMAT, environment, realmID);

    // Retrieve secrets
    KeyVaultSecret passwordSecret = secretClient.getSecret(passwordSecretId);
    KeyVaultSecret serverSecret = secretClient.getSecret(serverSecretId);

    // Extract credentials
    String password = passwordSecret.getValue();
    String server = serverSecret.getValue();

    LOGGER.info("Retrieved credentials for TM DB - Server: {}, Password: [PROTECTED]", server);

    // Create JDBC URL assuming a standard format
    String jdbcUrl = String.format("jdbc:sqlserver://%s:1433;databaseName=%s", server, TM_DB);

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(jdbcUrl);
    config.setUsername(USERNAME);
    config.setPassword(password);

    return new HikariDataSource(config);

} catch (Exception e) {
    LOGGER.error("Failed to create DataSource for realmID: {}", realmID, e);
    throw new RuntimeException("Failed to create DataSource", e);
}

}

I am getting this Exception can you please look into this issue,i took secrets generated by code by debugging and tried in Azure i am getting secret names correctly but still not able to get values 12:39:15.202 [reactor-http-nio-1] ERROR c.a.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://vault.azure.net/.default]: clientSecret is null or empty 12:39:16.297 [reactor-http-nio-1] ERROR c.a.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://vault.azure.net/.default]: clientSecret is null or empty 12:39:18.161 [reactor-http-nio-1] ERROR c.a.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://vault.azure.net/.default]: clientSecret is null or empty 12:39:21.707 [reactor-http-nio-1] ERROR c.a.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://vault.azure.net/.default]: clientSecret is null or empty 12:39:21.708 [reactor-http-nio-1] WARN c.a.s.k.secrets.SecretAsyncClient - Failed to get secret - tms-archive-dev-tms-db-password-be4f579f-43b4-4095-87d3-e15c3219fad9 Max retries 3 times exceeded. Error Details: clientSecret is null or empty

Aranipavan123 avatar Sep 24 '24 07:09 Aranipavan123

@billwert @g2vinay

github-actions[bot] avatar Sep 24 '24 07:09 github-actions[bot]

Thank you for your feedback. Tagging and routing to the team member best able to assist.

github-actions[bot] avatar Sep 24 '24 07:09 github-actions[bot]

Hello @Aranipavan123!

I have a few questions:

  1. What version of azure-identity are you using?
  2. Where and how are you constructing the ClientSecretCredential that you're giving to your SecretClient?
  3. What is the full callstack?

billwert avatar Oct 07 '24 16:10 billwert

Hi @Aranipavan123. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Oct 07 '24 16:10 github-actions[bot]

Hi @Aranipavan123, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

github-actions[bot] avatar Oct 14 '24 21:10 github-actions[bot]