Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

GoogleAPIs

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

GoogleAPIs

Automatic OAuth2 authorization via a local server and user WebBrowser (non WebView)

pascal
uses GoogleAPIs, GoogleAPIs.Auth;

var Google := TGoogleAPI.Create;

Auth

pascal
Google.ClientId := '36897688****ntent.com';
Google.ClientSecret := 'GOC*****Vlgifa';
Google.Scope := 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';

// async work
Google.Auth(
  procedure(Success: Boolean; Error: string)
  begin
    if Success then
    begin
      var UserInfo := Google.UserInfo.GetCurrent;
      if Assigned(UserInfo) then
      try
        UserName := UserInfo.Name;
        UserPicture := UserInfo.Picture;
      finally
        UserInfo.Free;
      end;
    end
    else
      ShowMessage(Error);
  end);

or

pascal
Google.Token := 'your_token';

MARS: https://github.com/andrea-magni/MARS