I try to use the Squidex CLI to export the information of a schema into a .csv file, however when I use the command:
sq content export banco-azteca:default --fields = id, version
I am getting the error:
ERROR: System.Security.SecurityException: Failed to retrieve access token for client ‘banco-azteca:default’, got HTTP Unauthorized.
at Squidex.ClientLibrary.Configuration.Authenticator.GetBearerTokenAsync()
at Squidex.ClientLibrary.Configuration.CachingAuthenticator.GetBearerTokenAsync()
at Squidex.ClientLibrary.Utils.AuthenticatingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
at Squidex.ClientLibrary.Utils.SquidexClientBase.RequestJsonAsync[T](HttpMethod method, String path, HttpContent content, QueryContext context, CancellationToken ct)
at Squidex.CLI.Commands.Implementation.ImExport.ExportHelper.ExportAsync(ISession session, IExportSettings settings, ILogger log, Func`2 handler)
at Squidex.CLI.Commands.App.Content.Export(ExportArguments arguments)
at Squidex.CLI.Commands.App.Content.Export(ExportArguments arguments)
at Squidex.CLI.Commands.App.Content.Export(ExportArguments arguments)
at Squidex.CLI.Commands.App.Content.Export(ExportArguments arguments)
at CommandDotNet.Execution.InvocationResultExtensions.GetResultCodeAsync(Object value)
at CommandDotNet.AppRunner.HandleException(Exception ex, IConsole console, CommandContext commandContext)
at CommandDotNet.AppRunner.Run(String[] args)
at Squidex.CLI.Program.Main(String[] args)
What it gives me to understand is that I am not correctly configuring the bearer token for authentication, my question is, using the CLI, where should it be configured?
Is there an example for this?
Tried adding it in CLI .configuration file but it didn’t work:
It is correct, I have done all the configuration that comes in the documentation, but when I get to the command that I showed above to export the data to a csv it sends me that error.
This is the way I add my config.
sq config add banco-azteca banco-azteca:default clienSecret sq config use banco-azteca
Even this command I get from the same Squidex portal when creating a client also offers you the way to connect.
Weird. It seems that you get a 401 while asking for a access token. Either your client id or secret is not correct or you have something else in the pipeline that blocks that. Like Nginx, Caddy or whatever?
It gives me to understand that it tries to find the access token in some configuration file but I cannot see anywhere that for the CLI that configuration of the token has to be done.
Regarding the client and the secret they are the same with which I connect via script by http, as I mentioned, these are the same ones that the squidex portal gives me.
It even has a copy to clipboard button to make it faster and you don’t have to copy letter by letter.