cannot connect to the server

bfuchs
bfuchs used Ask the Experts™
on
Hi Experts,

I have the following code which works fine for Win8 OS, while in Win7 it gives me an error, "cannot connect to the server".

Someone already helped me set this up in one Win7 pc, however now I need to move this over to another pc.

    Dim objHTTP As New WinHttp.WinHttpRequest



            Set objHTTP = New WinHttp.WinHttpRequest
 
            url = "https://MyAcct.caspio.com/oauth/token"
            objHTTP.Open "POST", url, False
            objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        
            objHTTP.Send "grant_type=client_credentials&client_id=MyID&client_secret=MySecretID"
        
            ResponseText = Right(objHTTP.ResponseText, Len(objHTTP.ResponseText) - 17)
            access_token = Left(ResponseText, InStr(ResponseText, """") - 1)

Open in new window


PS. this only happens when trying to access secured accounts (Hipaa).

As far I remember we did applied those attached last time, but so far this didn't help.

Thanks in advance.
x64.reg
TLS-1.x-on-Windows-7.zip
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Have you tried using GET instead of POST?
Hi,
This is an update operation that get doesn't fit here.
However tried with get and getting same error.
Thanks,
Ben

Commented:
I was not sure, but I have misused GET and POST incorrectly (which is probably why I was not sure.  :-)
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Commented:
Something bothers me about this line:
HTTP.Send "grant_type=client_credentials&client_id=MyID&client_secret=MySecretID"

I don't know why it would make any difference, but what would change if you defined string, build it from the pieces you have in that quoted area, and then send it as a string object. I wonder if it handles the string differently built that way.  

Grasping at straws, but I have always done that as objHTTP.send (sReq)
Hi,
Dont think anything wrong with the code.
since
1- its working on none hipaa accounts
2-its working on my other pc.
3- other windows versions dont have this issue.

the problem lays in some registry settings...

Thanks,
Ben

Commented:
Yea, I was taking a guess that maybe they handle strings differently. Sorry.
Martyn SpencerSoftware Developer / Linux System Administrator

Commented:
Given that you are using HTTPS. Is there any chance that the certificate for the link is valid and trusted by Windows 8 but not Windows 7? Can you securely connect to the server and if you check the certificate does it and the chain appear valid?
And/or have you tried it using a browser and manually logging in (i.e. IE11, Chrome, etc.)?
TLS or certificate issue would give you error messages that may be very helpful.
Hi Experts,
Please can you replace your attachments with code snippets
Here...
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000800

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\Passport Test]
"ConfigVersion"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\Tracing]

Open in new window

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000

Open in new window


the link is valid and trusted by Windows 8 but not Windows 7
No, according to vendor it should work, and as mentioned its working for regular accounts, except for Hipaa accounts.

have you tried it using a browser and manually logging in (i.e. IE11, Chrome, etc.)?
With the browser I get the following error in both pc's, the working one and the one I'm having problems with...
<Error>
<Message>Authorization has been denied for this request.</Message>
</Error>

Open in new window


Any other suggestions?

Thanks,
Ben
What O/S is the server running (2008, 2008R2, 2012, etc)?
Hi,
Which server, Caspio? No idea...
I'm using Win7
Thanks,
Ben
But; the server AND the client need to be on good terms with each other so you need to find out what is running on the server(s).
Login from a PC that works and run WINVER.  It will tell you
Hi,
This is no sense I have to look for this, its like saying "you're having trouble with MSFT product, find out which server they are  running..."
Thanks,
Ben
Martyn SpencerSoftware Developer / Linux System Administrator

Commented:
It makes absolute sense. If you are having problems authenticating with, or establishing an SSL connection with, a server, it's pretty important to understand what you are connecting to. Surely the team that runs the servers you are integrating with have a support group who are able to provide you with enough information. We are asking for more detail because its not clear to us based on the errors you are seeing.
Ok experts,
I've send an email to Caspio asking this, hopefully you will be able to resolve afterwards...
Will keep you posted.
Thanks,
Ben

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial