UC200T-GL: Communicating with Google Cloud Platform via HTTPS

Hi,

I am using a UC200T-GL to communicate with the Google Cloud Platform using HTTPS, and met with some problems.

The aim is to use a Google service account, to interact with Google Cloud Platform. For this to happen, we will first authenticate with the Google server by sending a JSON Web Token (JWT). The Google server will then provide us with an access token for further interaction (such as uploading files). This process is via HTTPS POST request. I have provided a link below that contains the details:
Using OAuth 2.0 for Server to Server Applications

In this aspect, I have tried two examples in the UC20 HTTP AT Commands manual to get a feel of how it works. Example 3.2.1 works (HTTPS with GET request), example 3.1.2.1 does not work (HTTP with POST request, I think it might be a permission issue). Then I went ahead to use QNavigator to test this out. The commands log is as follow, to setup the HTTP config and SSL, all executed without issue.

AT+QHTTPCFG=“contextid”,1
AT+QHTTPCFG=“sslctxid”,1
AT+QSSLCFG=“sslversion”,1,1
AT+QSSLCFG=“ciphersuite”,0xFFFF
AT+QSSLCFG=“seclevel”,1,0
AT+QHTTPCFG=“requestheader”,1

This was then followed by entering the authentication URL and the POST request to supply the JWT (JWT is the parameter in the body. The headers are also customized). As per the manual, each line of the customized header is appended with a character (not shown here).

AT+QHTTPURL=35,60
CONNECT
HTTPs://oauth2.googleapis.com/token
OK
AT+QHTTPPOST=847,80,80
CONNECT
POST /token HTTP/1.1
Host: oauth2.googleapis.com
Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=
OK

Then, I attempted to read the response from the Google server, and this is where there was an issue:

AT+QHTTPREAD=80
+CME ERROR: HTTP(S) no GET/POST requests

I checked the UC20 HTTP AT Commands manual, and this error has a number 705. What does this mean? Is it that the Google Server did not respond to the POST request?

Previously we have created a prototype program that performed the same task with the Google Cloud platform on Windows, and the communication worked without needing to configure SSL. Thus, we repeated this on the UC200T but it had the same “HTTP(S) no GET/POST” error, so we then configured SSL for the UC200T as shown above, using the broad SSL settings given in the example. Unfortunately the error still persisted.

May I know what could be a possible reason for this error? Or if anyone has any pointers I will be grateful. Thanks!

Best regards,
Victor

Hi,
I noticed the problem,You need access to HTTPS, with the packet header to post,but the header information you entered is HTTP。


In addition, 705 means HTTP(S) has no GET/POST request. In general, if we encounter this error, we should check the following:
1.Ensure that the URL entered through AT+QHTTPURL is valid and accessible.

  1. Ensure that the specified server supports GET/POST commands.

  2. Ensure that the PDP context is activated.

Best regards

Dear Link.Shan-Q,

Thank you for the reply.

Regarding the above question previously, we managed to get it solved. Although it is a HTTPS URL, however it does not appear to need SSL setup. Secondly, we also found that if we set = 0, and perform the POST request, Google Cloud will respond correctly and we can get the access token when we use QHTTPREAD.

Now, we are trying to upload a file to the Google Cloud platform, using the access token as an “Authorization” header in a POST request. This meant we have to set the request header setting = 1 in this case to generate the custom headers that include the access token. The QHTTPPOST request looks like this:

POST /upload/storage/v1/b/bucketname/o?uploadType=media&name=test.csv HTTP/1.1
Host: storage.googleapis.com
Content-Length: 100
Content-Type: text/csv
Authorization: Bearer access token here
… (the contents of the CSV file here, which is 100 bytes long).

We have checked the format of the headers using Google’s OAuth 2.0 playground, using the same headers, we could upload a file almost instantaneously there. On the UC20, we made sure that every line of the header was ended with a carriage return + line feed characters as per the manual.

However, after the POST request, the Google Cloud server did not respond even after a specified response timeout of 80s, and a +CME ERROR 728 was received. Checking the manual, error 728 means “wait HTTP response timeout”. I would like to check, what is a possible cause for this? Usually if the HTTP request was ill-formed or incorrect, the HTTP server will respond with HTTP error codes, but this time there was nothing.

Any advice or tip will be greatly appreciated! Many thanks!

Best regards,
Victor

Hello,
Can you please post this entire example of AT commands? I need to do a similar task to upload a file to google drive with the EG95 modem.
Thank you.