FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour gmail y OAuth
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
gmail y OAuth
Posted: Tue Feb 04, 2025 01:30 PM

Amigos

Ya no se pueden mandar correos desde gmail en aplicaciones de terceros como lo ven铆amos haciendo. Ahora hay que usar OAuth. No tengo la menor idea de como configurarlo. Alguien sabe? Gracias de antemano!

Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: gmail y OAuth
Posted: Tue Feb 04, 2025 11:01 PM
Hola Horacio,

Estamos implementando soporte OAuth2 para Gmail y Microsoft (Outlook, Live, Office 365).
El soporte para el env铆o de correos con OAuth2 estar谩 disponible en la pr贸xima versi贸n de FWH. 😃
Regards,

Lailton Fernando Mariano
Posts: 670
Joined: Wed Oct 19, 2005 06:41 PM
Re: gmail y OAuth
Posted: Wed Feb 05, 2025 07:01 PM

si es asi solo por eso compraria la version nueva ja ja ja un abrazo

yo nunca pude usar 365 para envio de mails seria un puntazo !!!

puedes dar algo de contexto como lo van a hacer

curl ? o ?

saludos

Wilson

Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: gmail y OAuth
Posted: Wed Feb 05, 2025 10:15 PM
Si, parte del codigo es con CURL para poder criar los token de comunicacion con los servicos oAuth2.
Cuando listo posto ejemplos con screenshots.

:D
Regards,

Lailton Fernando Mariano
Posts: 670
Joined: Wed Oct 19, 2005 06:41 PM
Re: gmail y OAuth
Posted: Thu Feb 06, 2025 02:15 AM

gracias estaremos atentos

saludos

Wilson

Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: gmail y OAuth
Posted: Thu Feb 06, 2025 10:36 AM
Lailton wrote: Si, parte del codigo es con CURL para poder criar los token de comunicacion con los servicos oAuth2.
Cuando listo posto ejemplos con screenshots.

:D
Lailton, esperando ansioso.

Gracias, tks.

Regards, saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: gmail y OAuth
Posted: Thu Feb 06, 2025 12:20 PM
karinha wrote:
Si, parte del codigo es con CURL para poder criar los token de comunicacion con los servicos oAuth2.
Cuando listo posto ejemplos con screenshots.

:D
Lailton, esperando ansioso.

Gracias, tks.

Regards, saludos.
+1

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 181
Joined: Thu Apr 17, 2008 02:38 PM
Re: gmail y OAuth
Posted: Sun Feb 09, 2025 07:06 PM
Excellent, we look forward to the next release
TIA :D
Posts: 151
Joined: Wed Oct 12, 2005 01:03 PM
Re: gmail y OAuth
Posted: Thu Feb 20, 2025 05:18 PM

Saludos

Si qued贸 implementado en esta 煤ltima versi贸n de FWH?

Marco Augusto Rodriguez Manzo

FWH January 2020 Xharbour 1.2.3

MySQL 5.0.19 Fastreport



PERZO SOFT

Sistemas Personalizados
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: gmail y OAuth
Posted: Mon Feb 24, 2025 05:51 PM

+1

Saludos/Regards,

Jos茅 Murugosa

"Los errores en programaci贸n, siempre est谩n entre la silla, el teclado y la IA!!"
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: gmail y OAuth
Posted: Mon Feb 24, 2025 06:26 PM
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: gmail y OAuth
Posted: Tue Feb 25, 2025 06:44 PM
Hola a todos,

Un ejemplo de c贸mo funciona Harbour + FWH con OAuth.


Aqu铆 tienen un sample del c贸digo.
Code Sample
#include "fivewin.ch"

static oGmail, hStore

function main()

	local oDlg
	local oName, cName := ""
	local oEmail, cEmail := ""
	local oPhoto, oSend
	local oConnect, oDisconnect

	hStore := readStore( hb_dirBase() + "gmail.json" )

	oGmail := TGmail():new()

	oGmail:setConfig( {;
		"client_id" => "your_client_id",;
		"client_secret" => "your_client_secret",;
		"redirect_uri" => "http://localhost:2025/";
	} )

	if !empty( hStore[ "token" ] )
		oGmail:setToken( hStore[ "token" ] )
	endif

	define dialog oDlg resource "GMAIL"

		redefine image oPhoto id 4002 of oDlg
		redefine say oName var cName id 4003 of oDlg
		redefine say oEmail var cEmail id 4004 of oDlg

		redefine button oDisconnect id 4005 of oDlg action onDisconnect( oDlg, { oPhoto, oName, oEmail, oSend, oDisconnect }, { oConnect } )
		redefine button oSend id 4006 of oDlg action onSendMail()

		redefine button oConnect id 4001 of oDlg action onConnect( oDlg, { oPhoto, oName, oEmail, oSend, oDisconnect }, { oConnect } )

		oDlg:bStart := { || updateControls( oDlg, { oPhoto, oName, oEmail, oSend, oDisconnect }, { oConnect } ) }

		oDlg:lHelpIcon := .f.

	activate dialog oDlg centered

	saveStore( hb_dirBase() + "gmail.json", hStore )

return nil

function onConnect( oDlg, aConnect, aDisconnect )

	local cToken

	if !oGmail:isAuth()
		cToken := oGmail:auth()
		if !empty( cToken )
			hStore[ "token" ] := cToken
		else
			msgStop( "Authentication failed!" )
		endif
	endif

	updateControls( oDlg, aConnect, aDisconnect )

return nil

function onDisconnect( oDlg, aConnect, aDisconnect )

	local cProfile := hb_dirBase() + "profile_gmail.jpg"

	oGmail:revoke()
	updateControls( oDlg, aConnect, aDisconnect )

	if hb_vfExists( cProfile )
		hb_vfErase( cProfile )
	endif

return nil

function onSendMail()

	if oGmail:send( "lailton@paysoft.com.br", "it is a test", "<b>Message from Gmail oAuth2</b>", .t., {} )
		msgInfo( "Mail sent!" )
	else
		msgStop( "Failed to send email. You may not have authorized the required permissions..." )
	endif

return nil

function updateControls( oDlg, aConnect, aDisconnect )

	local hUser
	local cProfile := hb_dirBase() + "profile_gmail.jpg"

	if oGmail:isAuth()
		hUser := oGmail:me()
	endif

	aEval( aConnect, { |o| o:hide() } )
	aEval( aDisconnect, { |o| o:hide() } )

	if hb_isHash( hUser )

		aEval( aConnect, {|o|o:show(),o:refresh()} )

		if !hb_vfExists( cProfile )
			oGmail:downloadUrl( hUser[ "picture" ], cProfile )
		endif

		// Load Profile Photo
		if hb_vfExists( cProfile )
			aConnect[1]:loadImage(, cProfile )
			aConnect[1]:refresh()
		endif

		aConnect[2]:setText( hUser[ "name" ] )
		aConnect[3]:setText( hUser[ "email" ] )

		aConnect[2]:update()
		aConnect[3]:update()

	else

		aEval( aDisconnect, {|o|o:show(),o:refresh()} )

	endif

	oDlg:update()

return nil

function readStore( cFile )

	local hStore

	if hb_vfExists( cFile )
		hStore := hb_jsonDecode( hb_memoRead( cFile ) )
	endif

	if !hb_isHash( hStore )
		hStore := {;
			"token" => "";
		}
	endif

return hStore

function saveStore( cFile, hStore )

	hb_memoWrit( cFile, hb_jsonEncode( hStore ) )

return hb_vfExists( cFile )
Ser谩 incluido hoy en FiveWin para la pr贸xima versi贸n :D
Regards,

Lailton Fernando Mariano

Continue the discussion