Can't connect a client / get access token

Hi,
I just set up a new Squidex instance (v 3.3.0) with docker.
I can log in, create an app, create schema and contents and clients. Everything works so far.

Now when I go to “Clients” and hit the “connect” button I see the explanations how to connect a client. Looks quite simple. But I can’t get it to work!

No matter if I try it with curl, Postman or Insomnia. With curl nothing happened at all. Both Postman and Insomnia return a “Bad Request” with the body: {“error”: “invalid_client”}

Ok, but if I take the Test Token that is also shown there and use it in my api requests, it works perfectly fine. I can access my contents of the api through Postman or Insomnia.

Here is how my request looked like in Postman:

Any idea what I’m doing wrong or what could be the problem? Help would be very appreciated. Thanks!
Johannes

Are you sure that there is no whitespace or so?

Can you use the Connect button in the UI and check if it works?
Can you check the logs?

Thanks for the quick response!

Ok, I now got it working with curl. The problem was the following:
At the end there is a single quote missing to close the string of -d! Here’s a screenshot where you can see it:

Maybe this could be fixed.

And in Postman and Insomnia it was my fault, because I passed “grant_type” and the rest as url parameters instead of creating a “Form URL Encoded” body and add them there…

1 Like

You mean after squidex-api? Will fix that.

FYI still not fixed.

1 Like

Sorry, thanks a lot for the hint. If you are using the open source version a PR for small fixes like this would be great.

I have fixed that now, sorry

1 Like

Hi,

I am experience similar issue, but could not get it to work. Below is my curl command

curl -X POST ‘https://cloud.squidex.io/identity-server/connect/token’ -H ‘Content-Type: application/x-www-form-urlencoded’ -d ‘grant_type=client_credentials&client_id=myapp:1fd654b3de06b3c47c96ffe0&client_secret=fbscvfcd87qjkkqfuqktwphvwgbho3tnzheun7gz6ecx&scope=squidex-api’

then got an error:
{“error”:“invalid_client”}

Am I missing something?

Thanks.

Are you sure that myapp:1fd654b3de06b3c47c96ffe0 is a correct client id? Have you compared it with the request that is done by the Management UI when you click the “Connect” button and follow the wizard?

I figured it out that I set wrong client_id in the command. It works! Thanks anyway.

I am also facing similar issue for only one app I am not able to generate the token
for other 3 app I am able to genrate the token

Not working 

curl --location --request POST ‘https://cloud.squidex.io/identity-server/connect/token
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Cookie: __cfduid=d17228f9e0ac377b102708aee1ca8a0c51616056774’
–data-urlencode ‘scope=squidex-api’
–data-urlencode ‘client_secret=client-secret’
–data-urlencode ‘client_id=appname-appname-appname-appname:publishing-reader’
–data-urlencode ‘grant_type=client_credentials’

working on below
curl --location --request POST ‘https://cloud.squidex.io/identity-server/connect/token
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Cookie: __cfduid=d17228f9e0ac377b102708aee1ca8a0c51616056774’
–data-urlencode ‘scope=squidex-api’
–data-urlencode ‘client_secret=clientcrdentails’
–data-urlencode ‘client_id=appname-appname-appname:publishing-reader’
–data-urlencode ‘grant_type=client_credentials’

Does it work when you use the cloud UI and then press the Connect button for an app?

can you please provide the link for the same I am not able to see the option,
Or please provide the direction steps for the same

https://docs.squidex.io/02-documentation/developer-guides/api-overview/postman#4-connect-to-your-app-using-a-client