cancel
Showing results for 
Search instead for 
Did you mean: 

Web client authorization by Token

hansg
Explorer
0 Kudos
879

How can I consume a rest webservices that uses a Token as authorization?

I created this function: ALTER FUNCTION "dba"."fn_AFAS_subscriptions"( ) returns long nvarchar url 'https://12345.rest.afas.online/ProfitRestServices/connectors/Profit_Subscriptions' type 'HTTP:GET' header 'Authorization: AfasToken PH..<base64 encoded="" string="">..uPg=='

When I call this function I get: Could not execute statement. The secure connection to the remote host failed: The connection was closed from the other side SQLCODE=-990, ODBC 3 State="HY000" Line 1, column 1 call "dba"."fn_AFAS_subscriptions"()

I tried also toe replace AfasToken to Bearer. Did not help also.

Is this a problem of authorization or TLS versions or ...?

The url work fine when I executed it with a online rest client test tool in the browser. So the token and url are correct.

Using SA17,0,10 build 6230.

Tia Hans

VolkerBarth
Contributor

Have you checked via web client logging via

CALL sa_server_option( 'WebClientLogging', 'ON' )

or dbsrv17 -zoc <logfile> whether the request looks correct?


See also this FAQ...

hansg
Explorer
0 Kudos

Thanks Volker.

With WebClientLogging I got this output:

[connid = 140, [30/10/2021:12:29:03.815 0200]] [connid = 140, [30/10/2021:12:29:03.815 0200], REQUEST] GET /ProfitRestServices/connectors/Profit_Subscriptions HTTP/1.0 Date: Sat, 30 Oct 2021 10:29:03 GMT Host: 12345.rest.afas.online Connection: close ASA-Id: 2ca4f......e202 Accept-Charset: UTF-8, * User-Agent: SQLAnywhere Authorization: AfasToken PHRxxxg.....==

[connid = 140, Error: socket closed by peer] [connid = 140, socket closed]

Another try with HTTP version set to 1.1: [connid = 140, [30/10/2021:12:57:50.043 0200], REQUEST] GET /ProfitRestServices/connectors/Profit_Subscriptions HTTP/1.1 Host: 12345.rest.afas.online Accept-Charset: UTF-8, * User-Agent: SQLAnywhere Authorization: AfasToken PHR....uPg== ASA-Id: 2ca4f...e202 Date: Sat, 30 Oct 2021 10:57:50 GMT Connection: close

[connid = 140, Error: socket closed by peer] [connid = 140, socket closed]

I created a C# Core application that could connect without problems. From the same PC as the database is running.

VolkerBarth
Contributor
0 Kudos

My idea was to use web clientogging to check whether the request sent by SQL Anywhere is similar to that of your test tool, particularly the treatment of the token. Can you confirm that?

Addionnally, you are using HTTPS in your original post, so does SQL Anywhere have access to the web server's root certificate?

Accepted Solutions (0)

Answers (0)