Nan
November 6, 2024, 2:33pm
1
I have…
Read the following guideline: Troubleshooting and Support | Squidex . I understand that my support request might get deleted if I do not follow the guideline.
Used code blocks with ``` to format my code examples like JSON or logs properly.
I’m submitting a…
Regression (a behavior that stopped working in a new release)
Bug report
Performance issue
Documentation issue or request
Current behavior
I’m tried to fetch bearer token but scripting return 400 error
Expected behavior
Fetch bearer token.
Minimal reproduction of the problem
const url = `https://some.service.inc/identity-server/connect/token`;
const headers = {
'Content-Type': `application/x-www-form-urlencoded`
};
const body = JSON.stringify({
grant_type: 'client_credentials',
client_id: 'clientId',
client_secret: 'clientSecret',
scope: 'squidex-api'
});
postJSON(url, body, (data) => {
var b = 2
}, headers);
Environment
App Name: test-app
Self hosted with docker
Self hosted with IIS
Self hosted with other version
Cloud version
Version: latest
Browser:
Chrome (desktop)
Chrome (Android)
Chrome (iOS)
Firefox
Safari (desktop)
Safari (iOS)
IE
Edge
Others:
Which error do you get? Is there a concrete message?
I see it now. PostJSON expects a JSON request body and response body. There is no solution to make these kind of queries at the moment.
Nan
November 7, 2024, 10:53am
5
So to use getJson method to get some data I should manually update every month bearer token?
Unfortunately yes, perhaps I can migrate fetch to the scripting engine to give more flexibility.
Nan
November 7, 2024, 6:20pm
7
It’s would be amazing, could you please do that?
1 Like
I have added a simple workaround for now:
var url = 'http://squidex.io';
var body = { key: 42 };
postJSON(url, body, function(actual) {
complete(actual);
}, {
'Content-Type': 'application/x-www-form-urlencoded'
})
When the header is set, the body is sent as url encoded string.
Nan
November 10, 2024, 8:30pm
9
I tried the next one request to get bearer token so that failed
var url = 'https://dev-admin.squidexsite.com/identity-server/connect/token';
var body = { grant_type: 'client_credentials', client_id: '{client id}', client_secret: '{token}', scope: 'squidex-api'};
postJSON(url, body, function(actual) {
complete(actual);
}, {
'Content-Type': 'application/x-www-form-urlencoded'
})
Could you please try request bearer token on your env?
Sorry, it was not merged nor deployed.
Nan
November 11, 2024, 1:00pm
11
Np, I saw you merged changes, will you create new release?
Not immediately, but every commit goes to a few thousand unit tests, api tests and e2e tests. There is no release test or something like that anyway.
Nan
November 11, 2024, 2:12pm
13
I pinned and try latest build from master.
Code:
const url = 'https://dev-admin.test.com/identity-server/connect/token';
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
const body = {
grant_type: 'client_credentials',
client_id: 'app-management:instruction-verifycation',
client_secret: 'xbszwjqigp6qwtynkh5oy5tepdrakw4shyu7xojd4ekx',
scope: 'squidex-api'};
postJSON(url, body, (data) => {
throw `Duplicate reference detected: ${JSON.stringify(data)} cooking instruction with SKU already exist.`;
}, headers, true);
So the same error:
{"statusCode":400,"headers":{"Content-Length":"175","Content-Type":"application/json; charset=UTF-8","Expires":"Thu, 01 Jan 1970 00:00:00 GMT","Date":"Mon, 11 Nov 2024 14:09:20 GMT","Server":"Kestrel","Cache-Control":"no-store","Pragma":"no-cache"},"body":"{\n "error": "invalid_request",\n "error_description": "The specified 'Content-Type' header is invalid.",\n "error_uri": "[https://documentation.openiddict.com/errors/ID2082\"\n}"} ](https://documentation.openiddict.com/errors/ID2082/%22/n%7D%22%7D)
Looks correct. I will test it again and inform you later.
I have tested it again and it works fine for me. Are you sure, you have the latest version.
Nan
November 11, 2024, 5:35pm
16
I used image with tag dev-8131
That’s the correct one. For me it works. Not sure how to reproduce it.
Nan
November 11, 2024, 6:31pm
18
May we quick call I can show it to you?
Btw do you use ignoreError as true and check data from callback?
Nan
November 11, 2024, 6:44pm
20
Could you please show me your script fully without editing