gmail y OAuth

Post Reply
horacio
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

gmail y OAuth

Post by horacio »

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!
User avatar
Lailton
Posts: 172
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 7 times
Contact:

Re: gmail y OAuth

Post by Lailton »

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
User avatar
wilsongamboa
Posts: 616
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 5 times

Re: gmail y OAuth

Post by wilsongamboa »

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
User avatar
Lailton
Posts: 172
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 7 times
Contact:

Re: gmail y OAuth

Post by Lailton »

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
User avatar
wilsongamboa
Posts: 616
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 5 times

Re: gmail y OAuth

Post by wilsongamboa »

gracias estaremos atentos
saludos
Wilson
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
karinha
Posts: 7944
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: gmail y OAuth

Post by karinha »

Lailton wrote: 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
Lailton, esperando ansioso.

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
FiveWiDi
Posts: 1240
Joined: Mon Oct 10, 2005 2:38 pm
Has thanked: 4 times
Been thanked: 4 times

Re: gmail y OAuth

Post by FiveWiDi »

karinha wrote: Thu Feb 06, 2025 10:36 am
Lailton wrote: 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
Lailton, esperando ansioso.

Gracias, tks.

Regards, saludos.
+1
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
User avatar
mauri.menabue
Posts: 164
Joined: Thu Apr 17, 2008 2:38 pm

Re: gmail y OAuth

Post by mauri.menabue »

Excellent, we look forward to the next release
TIA :D
User avatar
Marco Augusto
Posts: 147
Joined: Wed Oct 12, 2005 1:03 pm
Location: Cuernacava, Morelos Mexico
Has thanked: 3 times

Re: gmail y OAuth

Post by Marco Augusto »

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
User avatar
jose_murugosa
Posts: 1187
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay
Contact:

Re: gmail y OAuth

Post by jose_murugosa »

+1
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
karinha
Posts: 7944
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: gmail y OAuth

Post by karinha »

Mira,

viewtopic.php?p=277780#p277780

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Lailton
Posts: 172
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 7 times
Contact:

Re: gmail y OAuth

Post by Lailton »

Hola a todos,

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

Aquí tienen un sample del código.
Code Sample

Code: Select all | Expand

#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
Post Reply