Open FabricioJuliatto-DBC opened 2 years ago
Hey @FabricioJuliatto-DBC !
I'm also excited to create this kind of thing.
One of the things I was thinking to solve this kind of problem is to send ApiKey and ApiToken to retrieve a OAuth Token and put in ~/.vtex/session/tokens.json
or ~/.vtex/session/session.json
.
Just create a script that sends the follow curl:
curl --request POST \
--url http://{{account}}.vtexcommercestable.com.br/authorization/token \
--header 'Accept: application/json; charset=utf-8' \
--header 'Content-Type: application/json'
--header 'X-VTEX-API-AppKey: XXX' \
--header 'X-VTEX-API-AppToken: YYY'
And the response should look like this:
{
"applicationId": "vtex",
"token": "358a5bea-07d0-4122-888a-54ab70b5f02f"
}
I'll test and then come back to post if it worked.
Hey @FabricioJuliatto-DBC !
I'm also excited to create this kind of thing.
One of the things I was thinking to solve this kind of problem is to send ApiKey and ApiToken to retrieve a OAuth Token and put in
~/.vtex/session/tokens.json
or~/.vtex/session/session.json
.Just create a script that sends the follow curl:
curl --request POST \ --url http://{{account}}.vtexcommercestable.com.br/authorization/token \ --header 'Accept: application/json; charset=utf-8' \ --header 'Content-Type: application/json' --header 'X-VTEX-API-AppKey: XXX' \ --header 'X-VTEX-API-AppToken: YYY'
And the response should look like this:
{ "applicationId": "vtex", "token": "358a5bea-07d0-4122-888a-54ab70b5f02f" }
I'll test and then come back to post if it worked.
I'm taking a look at the VTEX ID documentations, I think it's the way, as the segment I mentioned above doesn't generate a token for authentication (JWT).
Hey!
Maybe I found the solution!
I've spent a few hours since then. I've tried to rewrite toolbelt login method. Then studying about VTEX providers I found one they didn't list. The provider key is called apptoken
.
Some searches on github VTEX's repositories related to /vtexid/apptoken
found the following file:
https://github.com/vtex/search-tests/blob/3ee5c1454f088cca83089296bd360f3793095ab0/ci/createSession.js
Look at this code snippet:
const payload = {
appkey: '<your-vtex-app-key>',
apptoken: '<your-vtex-app-token>',
}
return fetch(
`http://api.vtexcommercestable.com.br/api/vtexid/apptoken/login?an=${ACCOUNT}`,
{
method: 'POST',
body: JSON.stringify(payload),
headers: { 'Content-Type': 'application/json' },
}
)
.then((res) => res.json())
.then((res) => res.token)
I changed the base to: https://vtexid.vtex.com.br/api/vtexid/apptoken/login?an=${ACCOUNT}
and successfully returned the token and expiration date. I haven't tested the Token yet to see if it works, but just by passing a valid appKey and appToken it already gave me a token. Passing invalid keys, returns WrongCredentials
.
That's it Bro! If the solution was good, give a reaction!
PS: This file that i've found do exactly what you need. Because it's saves the token to session.json
and tokens.json
files
Hi, I'm trying to do this same thing with no success. I tried https://vtexid.vtex.com.br/api/vtexid/apptoken/login?an=${ACCOUNT} with postman + appkey & apptoken but didn't get any response back. Also tried the url from createSession.js and same result. Could it be that it no longer works? Coudn't even try the part of modifying session.json beacuse I never got the token.
hi all,
I am also trying to setup CICD for my application. I am able to login to vtex as a part of CI. Main problem now is, when I run any of below commnds
It prompts to enter "Y/N" options, which needs to be avoided in CI/CD. And also, it does not prompt always.
There is --yes flag which can be passed but it is not available for some of the above commands.
Any idea how to resolve this?
Hi , how could to solve the login on the CI?
You can pass and argument in the shell to answer Y or N:
echo Y | vtex link echo Y | vtex install etc
@MatiasRN
right way is: yes | yes [Quantity necessary] | vtex ...
Hi @rgangarde, how could to solve the login on the CI?
I'm using with GitHub actions this pipeline and works good! https://github.com/marketplace/actions/vtex-toolbelt-action
Hi @ericklb84, where should I write the bash commands to automatically respond to prompts? And when should I run them?
Hy Team, can i get the details of whole ci for vtex deployment. Generally we loign using vtex login acc_name then it pops for authentication , now how can i do in jenkins
What are you trying to accomplish? Please describe.
I am trying to setup a CI/CD pipeline for a new VTEX store. For example, I would like to be able to automatically release a new version of an app after a merge to main. However, I am not aware of any way of making releases other than using Toolbelt and I don't know how to use it in an automated environment. The main issue is the login: the OAuth dialog requires a human to interact with it. Is there any supported way of using Toolbelt in CI/CD or is there another supported way of publishing and deprecating apps that would allow me to do it without human intervention? Thanks!