-->
Page 1 of 2

ESP 8266 & Google OAuth

PostPosted: Sun Feb 20, 2022 4:04 pm
by t. stdenis
Looking for some help in implementing a version of this project. I'm using an ESP8266 as a webserver for the simple page to generate a code for OAuth to approve the device and generate a Refresh Token and Access Token.

Everything works until I get to the actual point of connecting with Google servers. I'm using <WiFiClientSecure.h> but this always fails and I don't know why.

Code: Select allif(!client.connect("https://accounts.google.com/o/oauth2/v2/auth", 443)){
  Serial.println(F("Connection to google server failed"));
} else{
  Serial.println("connected to google");
  ...

I have seen examples using client.connect, httpsClient.connect, and client_tcp.connect. none of those work. I have also tried all these connection methods with all the different URLs in the documentation given the various methods/devices including


Hoping there is someone who has been able to connect an ESP (orArduino) to Google OAuth and can help. Do I need another library for a an https connection (BearSSL)? Once I connect, do I need a certificate (google documentation doesn't indicate a certificate but not sure if that's just part of an https connection)? The aim is to connect to the Google Drive scope (https://www.googleapis.com/auth/drive.file) to upload pictures to a dedicated folder.

Re: ESP 8266 & Google OAuth

PostPosted: Tue Feb 22, 2022 7:50 am
by btidey
Haven't done this myself but when I was researching something similar before this looked like a useful library.

https://github.com/cotestatnt/Arduino-Google-API

Re: ESP 8266 & Google OAuth

PostPosted: Tue Feb 22, 2022 6:38 pm
by davydnorris
I'm not a big Arduino user but I know that in the underlying SDK you need two things to successfully connect to a secure connection
- you need to have NTP running and the time synced (mandatory)
- you need to supply a certificate chain for the destination so that the connection can be verified (this can be turned off in the code but I wouldn't advise it)

Re: ESP 8266 & Google OAuth

PostPosted: Wed Feb 23, 2022 2:44 am
by JurajA
@davydnorris OAuth is 'Google login'