Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer

 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

 100% (1)
Baixar · 519 visualizações · 18 páginas 1 de 18 TÍTULOS RELACIONADOS
 Pesquisar no documento 
 Revistas
Delphi XE5 ClientRest Google Drive
Enviado por Arja'un Tea
 Podcasts

Delphi XE5 ClientRest Google Drive Descrição completa
 Partituras
    
Salvar 100% 0% Incorporar Compartilhar
 Snapshots Course Content Dotloop External ESM_ServiceLayer_ LinQ
 API Developer…
Imprimir
 Documentos

Baixar 1 de 18  Pesquisar no documento 


 

Delphi XE5: REST Client Library


09/24/2013 Vlad 33 Comments Delphi in Web , Delphi Components 

As I mentioned earlier  , among other innovations in Delphi


XE5 adds support for authentication protocols OAuth 1.0, OAuth 2.0,  and with this
opportunity, and a new library called REST Client Library.  Since most of my work
have to deal with the writing of components and modules to work with various API -
Google and Facebook to Live Connect and Dropbox API, then, of course, this new lib
could not be left without my attention.

And check the usability of the new library, I decided on services, with whom I worke
recently, namely one of the API Google - Drive API. Running a little ahead, I will say
the components of the library can also be used in the development of mobile applicati
 but first things first.

Components REST Client Library


So all the work of the library is based on the use of three main components:

1.  Client (TRESTClient) 


2.  Request (TRESTRequest) 
3.  Answer (TRESTResponse) 

Saiba mais sobre a


Assinatura do Scribd
 Since most Web services require prior authorization of the user before the API to prov
Títulos relacionados
their resources in use, the REST Client Library also has four components for authenti

 Início and user authentication:

 Salvos 1.  TSimpleAuthenticator 


2.  THTTBasicAuthenticator 
3.  TOAuth1Authenticator  
4.  TOAuth2Authenticator 
 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
Finally
API Das an
l additional component can be identified

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 1/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
Finally, as an additional component can be identified
API Developer…
 Livros
Buscar 
component TRESTResponseDataSetAdapter,
 Enviar  PT   which
Entrarin some cases can be
Leia Gratuitamente used
Por 30 Dias to c

 Audiolivros data in JSON-dataset TDataSet.


Baixar 1 de 18 is J
 Pesquisar no documento
Immediately it should be noted that the basic data format for REST Client Library
 Revistas

 Podcasts Consider the work of some components of the library with Google Drive API. 

Log in Google Drive API. Testing connection.


 Partituras

 Snapshots

 Documentos

To get started with Drive API, we need to create a new project in the Console Google
get the values Client ID andClient Secret.  To learn how to do it, I say, for example, i
article " 
" Testing requests to API Google means Delphi.Component for Delphi XE
OAuthClient - XE3 
XE3 ". We assume that this time
ti me the work was carried out successfully
successfull y
you have the necessary information to get started with the service, and along with
wi th the
components of REST Client Library.

 Now create a new project Delphi XE5 and threw it on the main form
components TRESTClient, TRESTRequest, TRESTResponse and
TRESTResponse and TOAuth2Authenticat

Você está lendo


 Now we define the necessary parameters, uma amostra test the connection to G
and simultaneously
Drive API. Torne-se um membro do Scribd para ter acesso
total. Seus primeiros 30 dias são gratuitos.
Keys API access to the Design-Time 

Continue lendo com o teste


Choosing to form component OAuth2Authenticator1 and Object Inspector'e click on
link «Configure ...«: 
...«: 

Saiba mais sobre a


Assinatura do Scribd 
Títulos relacionados

 Início

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 2/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas In the window that opens, select the following values for the following fields:

Authorization-Endpoint: https://accounts.google.com/o/oauth2/auth
https://accounts.google.com/o/oauth2/auth  
 Podcasts   

 Partituras

 Snapshots
 

 Documentos

   Token-Endpoint: https://accounts.google.com/o/oauth2/token
https://accounts.google.com/o/oauth2/token  
   R edi r ct
ctii oon-E nd
ndppoi nt
nt::  urn: ietf: wg: oauth: 2.0: oob 
oob  
   Client-ID: Client ID value of your project
   Client-Secret:  Client Secret value of your project
   Access-Scope:  https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive  

As a result, the settings window component takes the following form:

 Now you can test the connection. Click the button Authorize


button Authorize and
 and if all the data are cor
will open Google confirmation of access to resources API:

Você está lendo uma amostra


Torne-se um membro do Scribd para ter acesso
total. Seus primeiros 30 dias são gratuitos.

Continue lendo com o teste

Saiba mais sobre a


Assinatura do Scribd 
Títulos relacionados

and after the access to the Settings window will be filled with fields group «Codes &
 Início
Tokens«:  
Tokens«:
 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 3/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas

 Podcasts

 Partituras
 

 Snapshots

 Documentos

 Now you can press «Apply»


«Apply» then
 then all the set values will be transferred to the component
 properties (including the values obtained from the Codes & Tokens).

Basically, now we can go to work with


wit h the resources API, because necessary access keys
we already have. However, when working with the library, we will most likely
likel y need to
obtain access keys in run-time,
run-ti me, and therefore, in this part of the article should consider
getting access keys without using the assistant discussed above.

Keys Access Run-Time  

For access keys in run-time, we need:

1.  Cause the window in which the user confirms the right of access
acces s to resources
2.  Get the value of code Você está lendo uma amostra
3.  Exchange code on Acess Token
Torne-se um membro do Scribd para ter acesso
total. Seus
In principle, these steps I saw a bunch primeiros
of times in the30 dias Now
blog. são gratuitos.
reproduce them using
features REST Client Library.
Continue lendo com o teste
Plug-in uses
uses the
 the main module of our application
module R E ST
ST.A
.Aut
uthe
hent
ntii ca
cattor .OA
.OAut
uth.We
h.Web
bF or m.Wi
.Win.
n.  This module contains a
form Tf
Tfrr m_OA
_OAut
uthWe
hWeb
bF or m, which can be used to authenticate the
user. Tfrm_OAuthWebForm contains TWebBrowser and the Close button in the designer
and looks as follows:

Saiba mais sobre a


Assinatura do Scribd

Títulos relacionados

 Início

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 4/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas

 Podcasts  

 Partituras

 Snapshots In form, the following new developments:

 Documentos property OnAfterRedirect: TOAuth2WebFormRedirectEvent read FOnAfterRedirect write FOnAfterRedirect;

property OnBeforeRedirect: TOAuth2WebFormRedirectEvent read FOnBeforeRedirect write FOnBeforeRedirect;

property OnTitleChanged: TOAuth2WebFormTitleChangedEvent read FOnBrowserTitleChanged write FOnBrowserTitleChanged;

type

TOAuth2WebFormRedirectEvent = procedure (const AURL: string; var DoCloseWebView: boolean) of object;

TOAuth2WebFormTitleChangedEvent = procedure (const ATitle: string; var DoCloseWebView: boolean) of object;

OnBeforeRedirect  and
 and OnAfterRedirect  triggered
 triggered before and after we redirect to another
URL in the browser.OnTitleChanged 
browser.OnTitleChanged  triggered
 triggered when the browser changes the properties
of Title.
Title.  

According to the 
the documentation on the Google OAuth 2.0. 
2.0. , after the user gives permission
to access your data, Google will return us the value AuthCode, which we have to be

exchanged for an access key. Meaning AuthCode also issued


is sued in Title as a string
strin g
type «Success code = ... ..«. 
..«. 

Thus obtaining access to key API Google Drive in run-time can be as follows:

var wf: Tfrm_OAuthWebForm;


Você está lendo uma amostra
begin
Torne-se um membro do Scribd para ter acesso
total. Seus primeiros 30 dias são gratuitos.
// Create the window with the browser to redirect the user to the Google homepage

wf: = Tfrm_OAuthWebForm.Create (self); Continue lendo com o teste


try

// Define event handler change Title

wf.OnTitleChanged: = TitleChanged;

// Show the window opens in the browser URL to access a form of confirmation

wf.ShowModalWithURL (OAuth2Authenticator1.AuthorizationRequestURI);

finally

wf.Release;

end;

Saiba mais sobre a // Replace AuthCode on AccessToken

Assinatura do Scribd

Títulos relacionados
OAuth2Authenticator1.ChangeAuthCodeToAccesToken;

 Início // Display the key values in the Memo

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 5/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas

 Podcasts

 Partituras

 Snapshots

 Documentos

Saiba mais sobre a


Assinatura do Scribd 
Títulos relacionados

 Início

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 6/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros
Você está lendo uma amostra 

Baixar 1 de 18
Desbloqueie o acesso completo
 Pesquisar no documento 
 Revistas
(páginas 7-16) fazendo upload de
 Podcasts documentos ou com um teste
gratuito de 30 dias.
 Partituras
Continue de graça

 Snapshots

 Documentos

Saiba mais sobre a


Assinatura do Scribd 
Títulos relacionados

 Início

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 7/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas

 Podcasts

 Partituras

 Snapshots

 Documentos

Saiba mais sobre a


Assinatura do Scribd

Títulos relacionados

 Início

 Salvos


 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 8/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas

 Podcasts
Recompense a sua curiosidade
 Partituras Tudo o que você quer ler.
A qualquer hora. Em qualquer lugar. Em qualquer
 Snapshots dispositivo.

 Documentos
Leia gratuitamente por 30 dias

Sem compromisso. Cancele quando quiser.

Compartilhar este documento


    

Interesses relacionados

Interface De Programação De Aplicativos Transferência De Estado Representacional

Biblioteca (Computação) Rede Mundial De Computadores Tecnologia

Documentos semelhantes a Delphi XE5 ClientRest Google Drive

Course Content Dotloop External API ESM_ServiceLayer_De LinQ_XML Api integrations


Developer Guide
ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR
Douglas Kangoni achhu Ekta Siwani Kaushik Poojari Encéfalo SAS

Mais de Arja'un Tea

Saiba mais sobre a


 
Assinatura do Scribd
Títulos relacionados

 Início

FireDac EMC- sewing clutch motor sewing clutch motor Chat Room Socket
 Salvos
WIRING_BTS7960 pulley.pdf pulley.pdf
ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR 
Arja'un Tea Arja'un Tea Arja'un Tea Arja'un Tea Arja'un Tea
 Best-sellers

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l

https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 9/10
24/09/2020 Delphi XE5 ClientRest Google Drive | Application Programming Interface | Representational State Transfer
API Developer…
 Livros
Populares em O Auth
Buscar   Enviar  PT  Entrar Leia Gratuitamente Por 30 Dias

 Audiolivros

Baixar 1 de 18  Pesquisar no documento 


 Revistas


 Podcasts

 Partituras

 Snapshots OpenSAP Hcp1 Week Google Drive api_rest Experience API OAuth Request
2 Transcript Release v0.95 Scenarios
ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR ENVIADO POR
 Documentos
Pallavi Koppula hieuanhanh Dan Niel Hareesh Kancha… deals4kb

SOBRE SUPORTE

Sobre o Scribd Ajuda / FAQ

Imprensa Acessibilidade

Nosso blog Ajuda de compra

Junte-se à nossa equipe! AdChoices

Contate-nos Editoras

Entre hoje

Convidar amigos

Presentes

Scribd para Empresas

LEGAL
   
Termos

Privacidade

Direitos autorais

Copyright © 2020 Scribd Inc. . Ver livros . Diretório do site . Idioma do site: português

Títulos relacionados

Course Content Dotloop External ESM_ServiceLayer_ LinQ_XML Api integrations seam_reference API Nuts Bolts
API D l
https://pt.scribd.com/document/423660655/Delphi-XE5-ClientRest-Google-Drive 10/10

You might also like