Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthenticationException: error #3508

Open
sangramjadhavbhtc opened this issue Jan 9, 2024 · 10 comments
Open

AuthenticationException: error #3508

sangramjadhavbhtc opened this issue Jan 9, 2024 · 10 comments
Assignees

Comments

@sangramjadhavbhtc
Copy link

Trying conan.tools.files.download() from https://docs.conan.io/2/reference/tools/files/downloads.html but facing issue

Error:

C:\Users\sangram.jadhav\handle_sources>conan source .
conanfile.py (hello/4.0.1): Calling source() in C:\Users\sangram.jadhav\~~\Source handle\handle_sources
ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 32
download(self, "https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip", "myrepo123.zip", auth=("sangram.jadhav", "XYZ"))

AuthenticationException:

Conanfile:

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import copy, get, download, unzip, check_sha1

class helloRecipe(ConanFile):
name = "hello"
version = "4.0.1"

settings = "os", "compiler", "build_type", "arch"

def source(self):

    download(self, "https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip", "myrepo123.zip", auth=("sangram.jadhav", "password"))
@sangramjadhavbhtc sangramjadhavbhtc changed the title Authentication error AuthenticationException: error Jan 9, 2024
@memsharded memsharded self-assigned this Jan 9, 2024
@memsharded
Copy link
Member

Hi @sangramjadhavbhtc

Thanks for your report.

auth=("sangram.jadhav", "password")

First, I'd like to start with a recommendation, even if the download() tool allows passing the auth, try to use this as the very last resort. Adding credentials in the source files of conanfile.py recipes is a high risk. There are several other ways to approach this:

  • If that is a git repo, you can use your standard git authentication mechanisms like ssh-keys in the developer and CI computers to do a git clone of the repo, instead of downloading the source
  • There is a new source_credentials.json file, check https://docs.conan.io/2/reference/config_files/source_credentials.html, to put credentials instead of putting them in conanfiles.

Of course, it would be good to validate that you have the right credentials, can you download that file with a wget or curl command using that user/password? This would be the first thing to try.

@sangramjadhavbhtc
Copy link
Author

@memsharded Thank you for attending to my issue and valuable suggestions.

can we control the downloads? A specific person can download the file from a remote repo. (in my case bitbucket) using conan.

and one more question
what is the "data" in this command;
get(self, data["url"], sha256=data["sha256"], strip_root=data["strip_root"])

I have also tried this :
get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"])

but getting error:
C:\Users\sangram.jadhav\~~\Source handle\handle_sources>conan source .
conanfile.py (hello/4.0.1): Calling source() in C:\Users\sangram.jadhav\~\Source handle\handle_sources
ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 14
get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"]) ConanException: Cannot deduce file name from the url: 'https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip'. Use 'filename' parameter.

@memsharded
Copy link
Member

can we control the downloads? A specific person can download the file from a remote repo. (in my case bitbucket) using conan.

With exactly the same credentials? It should be good to verify in your machine that you are trying it is possible with those credentials, to rule out other possible credentials, machine-setup or system configurations issues.

The second error is expected and the error message is giving a hint Use 'filename' parameter.. As the URL is complex, it cannot deduce the filename to download, so it needs the filename=xxxx parameter.

@sangramjadhavbhtc
Copy link
Author

sangramjadhavbhtc commented Jan 9, 2024

@memsharded

The second error is expected and the error message is giving a hint Use 'filename' parameter.. As the URL is complex, it cannot deduce the filename to download, so it needs the filename=xxxx parameter.

you mean to say like this?

get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], filename="myrepo123.zip", sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"])

filename="myrepo123.zip",

Now It is showing AuthenticationException

ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 14 get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], filename="myrepo123.zip", sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"]) AuthenticationException:

@sangramjadhavbhtc
Copy link
Author

Along with conanfile, the source_credentials.json file is also added in the same folder. Still facing issue of AuthenticationException

source_credentials.json:
{
"credentials": [
{
"url": "https://bitbucket.bhtc.com/users/sangram.jadhav/repos/conan_trail/browse",
"user": "sangram.jadhav",
"password": "password"
}
]
}

@memsharded
Copy link
Member

Along with conanfile, the source_credentials.json file is also added in the same folder.

That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?

Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your url in source_credentials.json is wrong.

I'd still like to see a curl or wget command that successfully download the file in the computer, without using Conan. We need to rule out other potential factors.

@sangramjadhavbhtc
Copy link
Author

That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?

No, I don't know how to add data directly to the cache. only exports_sources = is known to me.

Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your url in source_credentials.json is wrong.

Now, the Same links are filled at both places but still not working

{
"credentials": [
{
"url": "https://bitbucket.~.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip",
"user": "sangram.jadhav",
"password": "password"
}
]
}

I'd still like to see a curl or wget command that successfully download the file in the computer, without using Conan. We need to rule out other potential factors.

I am using a Windows machine for development. is curl useful in this case?

@memsharded
Copy link
Member

No, I don't know how to add data directly to the cache. only exports_sources = is known to me.

These are some useful resources to learn:

"url": "https://bitbucket.~.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip",

It is not the same link. It is the same base URL of the domain to cover with the credentials.

I am using a Windows machine for development. is curl useful in this case?

yes, you can get curl for example if using cmder or it is possible to install curl in Windows too

@sangramjadhavbhtc
Copy link
Author

Along with conanfile, the source_credentials.json file is also added in the same folder.

That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?

Oh, understood, it is a conan home folder. source_credentials.json is added in conan cache.

image

Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your url in source_credentials.json is wrong.

image

Just for the feedback; these are the changes I have made. But, the result is the same as the previous.

yes, you can get curl for example if using cmder or it is possible to install curl in Windows too

Ok I will try this. Thank you

@memsharded
Copy link
Member

I am afraid the url is still wrong, it needs to include the protocol. Please check the examples in https://docs.conan.io/2/reference/config_files/source_credentials.html, they all include the protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants