indigo-dc / oidc-agent

oidc-agent for managing OpenID Connect tokens on the command line
MIT License
111 stars 30 forks source link

Failed to parse JSON while obtaining mytoken #580

Open Nithe14 opened 3 months ago

Nithe14 commented 3 months ago

Attempting to obtain a mytoken results in an error. When running the following command:

oidc-token <profile_name> --mytoken="{\"capabilities\": [\"AT\"]}"

the browser opens with a mytoken creation approval page. After debugging, I noticed that the function assigned to the "Continue" button propably has an incorrect name: _approve() instead of approve(), which is why the button doesn't work initially. After manually changing the function name in the HTML source and accepting the token creation, oidc-agent returns the error:

Error: could not parse json

I'm not certain if the problem might be related to the mytoken server itself, as there are no logs for this error on the server.

The profile was originally created using the following command:

oidc-gen -m --prompt=cli --flow=device --mytoken-url=$MYTOKEN_URL --issuer=$ISSUER --redirect-uri=http://localhost:8080 --scope=openid --scope=profile --scope=offline_access --mytoken-profile="{\"capabilities\": [\"AT\", \"create_mytoken\", \"manage_mytokens\", \"tokeninfo\"]}" <profile_name>

Obtaining access_token works correctly.

As I understand the new mytoken should be created with capabilities no greater then the original mytoken stored in the profile.

zachmann commented 3 months ago

Sorry for the delayed response, I was on vacation. I can confirm the problem and will look into it.

zachmann commented 3 months ago

I did some investigations, and indeed this seems to be caused by mytoken. I assume you use your own mytoken server. Can you test the version currently on the prerel branch?

Nithe14 commented 2 months ago

Yes, I host it myself. I've tested the prerel branch of the mytoken server, and it works perfectly fine. Thank you! I look forward to the main release.