cloudinary / cloudinary_npm

Cloudinary NPM for node.js integration
622 stars 316 forks source link

Must supply api_key #664

Open sohaibkhan-007 opened 1 month ago

sohaibkhan-007 commented 1 month ago

There was an unexpected error (type=Internal Server Error, status=500). Must supply api_key java.lang.IllegalArgumentException: Must supply api_key

//here is my proprties file code

cloudinary configurations

cloudinary.cloud.name=ddxv9r6it cloudinary.api.key=884911427739699 cloudinary.api.secret=DELETED

//its AppConfig file @Configuration public class AppConfig { @Value("${cloudinary.cloud.name}") private String cloudName; @Value("${cloudinary.api.key}") private String apiKey; @Value("${cloudinary.api.secret}") private String apiSecret; @Bean public Cloudinary cloudinary() { ObjectUtils.asMap( "cloud_name", cloudName, "api_key", apiKey, "api_secret", apiSecret); return new Cloudinary(); } }

PixelCook commented 1 month ago

Hey there,

Please never share your API secret anywhere publically. I've gone ahead and deleted this from your post but please go into your account and create a new API key to use.

That being said it looks like you're trying to inject values from a properties file into your Java application using Spring's @Value annotation, but it appears there might be a small issue with your configuration.

I'm not super familiar with Java but I believe you need to declare a new instance of Cloudinary:

import com.cloudinary.*; ... Cloudinary cloudinary = new Cloudinary(ObjectUtils.asMap( "cloud_name", "my_cloud_name", "api_key", "my_api_key", "api_secret", "my_api_secret", "secure", true));

Check out our docs for more info https://cloudinary.com/documentation/java_integration#installation_and_setup