No credentials could be found from valid profile using ProfileConfigFileAWSCredentialsProvider #2063
-
Hi, I am using Aws::Auth::ProfileConfigFileAWSCredentialsProvider() with specified profile to access AWS service. But I found the credentials is always empty. The credentials I used is valid as it could work if I put it under my $HOME/.aws/credentials. I did not set AWS_SHARED_CREDENTIALS_FILE and AWS_PROFILE. I am not sure what is wrong. Or my profile format is not correct? I am using on Windows 10 Pro with AWS SDK 1.9.220 --code
--the profile I passed --aws log with Debug level, to test profile I removed C:\Users\zhang.aws\credentials [INFO] 2022-08-29 20:44:17.012 Aws::Config::AWSConfigFileProfileConfigLoader [9076] Unable to open config file C:\Users\zhang.aws\credentials for reading. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi Roy, First of all, I have updated profile and credential file parsing recently, starting with 1.9.335. It brings a better compatibility support with different AWS SDK language clients.
Secondly, in your message I see following:
You can check how SDK fetches your %userprofile% dir on Windows: FileSystem.cpp. From MS docs, GetUserProfileDirectoryW does not set the last backslash, but SDK has a logic to append it anyway.
If the issue is still reproducible with the latest changes and correct or not set env variables, we'll be glad to investigate it further. Best regards, |
Beta Was this translation helpful? Give feedback.
-
Hi Sergey, Thanks for your quick reply! The "" is not missed. It should be a display issue. I copied again here. [DEBUG] 2022-08-29 20:44:17.012 FileSystem [9076] Environment value for variable USERPROFILE is C:\Users\zhang Let me try the newest version. Regards, |
Beta Was this translation helpful? Give feedback.
-
Hi Sergey, I have figured out the root cause. It is my problem. The profile should be the profile section name like default1 or default2, instead of the while profile string. [default1] [default2] The SDK description here is correct. But if it has an example that will be helpful. As the profile is easy to be understood as a profile file name. I tried a file name, then tried a profile string before I used the profile name. I used one day to figure out this. Regards, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi Sergey,
I have figured out the root cause. It is my problem. The profile should be the profile section name like default1 or default2, instead of the while profile string.
[default1]
aws_access_key_id=xxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxx
[default2]
aws_access_key_id=xxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxx
The SDK description here is correct. But if it has an example that will be helpful. As the profile is easy to be understood as a profile file name. I tried a file name, then tried a profile string before I used the profile name. I used one day to figure out this.
https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_auth_1_1_prof…