Automation: how to authorize to private Composer Repository?

In automation job I need to install dependencies from private Composer Repository created in Space.

I've found in documentation that I can use JB_SPACE_CLIENT_ID, JB_SPACE_CLIENT_SECRET and JB_SPACE_CLIENT_TOKEN env variables.

The problem is that Composer Repository requires to use username and token.
I have tried using client id and client secret like this but it didnt' work.
composer config --global --auth http-basic.packages.jetbrains.space "${'$'}JB_SPACE_CLIENT_ID" "${'$'}JB_SPACE_CLIENT_SECRET"

I could use JB_SPACE_CLIENT_TOKEN but I couldn't find the username anywhere.

I've tried to use the bearer auth like this but that didn't work either:
composer config --global --auth bearer.packages.jetbrains.space "${'$'}JB_SPACE_CLIENT_TOKEN"

0
2 comments

Michal - hi,

Thank you for reaching out to us! I apologize for the delay with a reply.

Using your Space user name and password for authorization is not recommended although possible (https://www.jetbrains.com/help/space/authenticate-in-packages.html#authentication), please try to use your Space user name and a personal token instead (https://www.jetbrains.com/help/space/authenticate-in-packages.html#space_account).
The Space user name should be specified on the "My Profile" page in the "Contact Details" section.

Please let me know how it's going and if further assistance is needed.

0

Hello Margarita,

I'm sorry it looks like I wasn't clear in my question.

I don't have problem with authorization when I want to access composer repository directly (using my username and personal token when accessing).

The issue is when I try to authorize inside of automation job.
I've tried to follow this guide https://www.jetbrains.com/help/space/authenticate-in-packages-a.html

Here is part of .space.kts file that tries to create authorization for composer and run composer install.

shellScript {
content = """
composer config --global --auth http-basic.packages.jetbrains.space "${'$'}JB_SPACE_CLIENT_ID" "${'$'}JB_SPACE_CLIENT_SECRET" && \
composer install --quiet && \
... some other commands to run migrations and tests ...
"""
}

I've also tried to us JB_SPACE_CLIENT_TOKEN variable as bearer:

shellScript {
content = """
composer config --global --auth bearer.packages.jetbrains.space "${'$'}JB_SPACE_CLIENT_TOKEN" && \
composer install --quiet && \
... some other commands to run migrations and tests ...
"""
}

Based on this guide https://www.jetbrains.com/help/space/get-composer-packages.html I think I need to use http-basic authentication with username and token. I know that I can use JB_SPACE_CLIENT_TOKEN env variable to get automation's token. But I couldn't find any env variable that would contain automation's username.

0

Please sign in to leave a comment.