PDA

View Full Version : oAuth2 - Obter email e login



Renato.Antonacci
26-Jul-2021, 09:11 AM
Bom dia.

Estou tentando aprender algo mais sobre o uso do oAuth2. Já consigo fazer a autenticação na conta Google para acesso ao Calendário. Porém, eu queria usar a autenticação do Google para obter o email e o nome do usuário que fez a autenticação. Já cadastrei minhas credenciais para uso com a API do google, mas estou tendo dificuldade em obter esses dois dados. Email que autenticou e nome do usuário. Alguém já fez isso?

EDIT-1: Até a parte de solicitar as credenciais de do google e retornar com sucesso ao procedimento OnLogin eu já consegui. Agora me falta apenas como recuperar o eMail e Nome do usuário que autorizou.
Utilizei o Scopo: Send AddParam "scope" "https://www.googleapis.com/auth/userinfo.profile"

EDIT-2: Consegui. Encontrei os escopos corretos e consegui retornar todos os dados que preciso. Agora consigo autenticar um usuário pela sua conta do google



Scopes


https://www.googleapis.com/auth/userinfo.email
Veja o seu endereço de e-mail


https://www.googleapis.com/auth/userinfo.profile
Veja suas informações pessoais, incluindo quaisquer informações pessoais que você disponibilizou publicamente




Obrigado

pacorbett
4-Feb-2024, 08:53 AM
Renato, Bom dia !!
Estou atrás do coAuth também, mas baixei a versão 2024 beta 2 para verificar. Não existe nenhum pacote coAuth2 nessa versão... Onde pegou a sua versão - imaginei que existiria algum pacote... é antigo já o cOAuth, não ? achei um numa literatura que tenho guardado aqui, mas é uma versão de 2015 se não me engano... e é pelo Auth1 - é isso mesmo ? -preciso montar um acesso de loja por ela. Grato se pude me ajudar.

Mike Peat
5-Feb-2024, 05:18 AM
PMFJI (and also pardon me for posting here in English :p): a long time ago now (~2015) I wrote an OAuth2 package (https://github.com/DataFlexCode/OAuth2) (it isn't just in DataFlex, but also JavaScript) which these days works for both Web and Windows (via an embedded browser) applications in versions from 18.1 up (the current version needs 19.1+ because it uses JsonObjects, but earlier versions didn't).

There is also a Chilkat mechanism that people have used successfully (I can't tell you much about that because I've never used it).

However... since I first demoed mine at Synergy in Seattle, Google have started to impose restrictions on their APIs, involving having a very expensive validation process ($$,$$$!) in order to access them. I think that might be what you are having a problem with. I have not kept up with how far Google have gone with this, but it certainly worth checking.

Mike

pacorbett
5-Feb-2024, 07:32 AM
Thanks for listening, Mike. I think it really is your pkg that I have here as literature. But then today we should use the JsonObjects class? Thanks. I was looking for something specific for this. I'll study the class. Thank you for the answer.