Jump to content

rvk

Members
  • Content Count

    126
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by rvk


  1. 16 minutes ago, Angus Robertson said:

    Do you have a Goggle reference that states in what circumstances plain passwords are supported?

    Google never stated that plain passwords are not supported anymore altogheter.

    BUT they DID state that you own Google password can't be used anymore for mail (that was the "Less secure apps"-options).

    This change was implemented on May 30, 2022.

     

    If you have enabled 2FA you can still create an App password here:

    https://myaccount.google.com/security

    (just try it yourself, but you do need 2FA enabled on that account, so you can try it with your high security account :))

     

    The steps are explained in this post:

    https://support.google.com/accounts/thread/163639845?hl=en&msgid=163700497

     

    Quote

    Option 2: Continue using a legacy email client
    Going forward, you will need to follow the steps below if you want to continue to access your Gmail using a legacy mail client. By following these steps. you should be aware that your Google account is less secure because it's linked to a mail client that doesn't support modern authentication.

     

    Other help page of Google for Signing in with App passwords:

    https://support.google.com/mail/answer/185833?hl=en-GB

     

    So... yes, Google has removed the "Less secure apps" options where you could still login with your Google username and Password, but the options of App passwords still remains and will continue to work because Google never stated that App passwords will go away.

     


  2. 13 hours ago, Angus Robertson said:

    In June 2022 Google stopped accepting traditional authentication methods for it's SMTP and POP3 email servers, instead requiring OAuth2, and I believe Microsoft is doing the same from October 2022.

    Just FYI. Once again (to eliminate any confusion). Google is not requiring OAuth2. You can still create app passwords and use them with your username for sending and accessing mail. OAuth2 is just another option (besides the app passwords) of doing it. App passwords work without any modification of existing code.

     

    OAuth2 is always handy if it's implemented but it isn't the only option for Gmail. Even after the change on May 30, 2022.

     

     

    • Like 1

  3. Do you have any (text-)search software. Like grep, notepad++, ScanFS or other?

    You can search the complete source directory (all *.pas and *.inc) for SetupDiGetDevicePropertyW.

     

    For example, I did:

    C:\Program Files (x86)\Embarcadero\Studio\19.0\source>grep -d SetupDiGetDevicePropertyW  *.pas
    rtl\net\System.Win.Bluetooth.pas
    ): BOOL; stdcall; external SetupApiModuleName name 'SetupDiGetDevicePropertyW' delayed;
    
    C:\Program Files (x86)\Embarcadero\Studio\19.0\source>

    (or as attached in notepad++)

    1190410697_2022-07-0719_57_47-Window.thumb.png.2e5804fe1d275deea727356094a9b8b1.png

     


  4. 2 hours ago, Remy Lebeau said:

    Delphi does not call that function, so something in your project must be.

    I see that Delphi 10.2 has a call to SetupDiGetDevicePropertyW in System.Win.Bluetooth.

    (in Embarcadero\Studio\19.0\source\rtl\net)

     

    @JDRenk Are you also using System.Win.Bluetooth by any chance (specifically TWinBluetoothLEDevice)?

     


  5. First: Ieks. Extended ascii characters in a table name? I wouldn't do that.

     

    Second: What is "FROM tablename := :A". Does that work in SQL?

    Can you parameterize a tablename in a query in ADO?

     

    Or did you mean "FROM tablename WHERE field := :A" ?

     


  6. On 5/16/2022 at 2:27 PM, Henry Olive said:

    Also when i backup with FDBackUp,  BackUp File's size same as actual database 

    Is that normal ( No compress )  ?

    Not sure which backup program this is but assuming it uses the backup service of Firebird it is weird that your filesize of the backup is the same as the database itself. Normal gbak already strips out a lot during backup.

     

    Depending on the size and usage of your database, the backup should be at least a couple of bytes smaller but it could even be as much as 50% of the DB size.

     

    Or does FDBackUp do a backup cycle and a restore cycle right after?

    (but even then I would expect some bytes less)


  7. I see that the code is a mess concerning the use of override instead of overload.

     

    If you compile this, watch all the warnings you get (and fix them).

     

    I think TDataSet has changed since the creation of this additional code and you now need to use overload on many places.

    Otherwise your own SetData etc aren't executed and your records aren't populated (which you are experiencing).

    You'll notice the execution of your code never reaches your EditDataSet1PerformSetFieldData() event.

     


  8. 6 minutes ago, Henry Olive said:

    Sorry i'm new in Firebird.

    No problem. We've all got to start somewhere :classic_biggrin:

     

    6 minutes ago, Henry Olive said:

    What am i doing wrong ?

    The EXECUTE BLOCK method groups multiple SQL commands together. But if you are using a STORED PROCEDURE all those commands are already grouped together by the STORED PROCEDURE itself. So you can remove that statement.

     

    This should work in FlameRobin (under Object > New > Procedure when connected to the database).

    SET TERM ^ ;
    CREATE PROCEDURE TRIGGERSINACTIVE AS
    DECLARE VARIABLE NOMTABLE varchar(100);
    DECLARE VARIABLE REQ1 Varchar(100);
    BEGIN
      for select x.RDB$TRIGGER_NAME from rdb$triggers x where
        rdb$trigger_source is not null and (coalesce(rdb$system_flag,0) = 0)
        and rdb$trigger_source not starting with 'CHECK' into :NOMTABLE
      do
      begin
        NOMTABLE=trim(NOMTABLE);
        req1= 'ALTER TRIGGER ' || :NOMTABLE || ' INACTIVE;';
        execute statement req1;
      end
    END^
    SET TERM ; ^


     


  9. 46 minutes ago, Henry Olive said:

    This time i get Token Unknown Line 1 Column 279  ?.

    Maybe it's because ExecSQL with CommandText only expects one SQL command. Not an entire EXECUTE BLOCK.

     

    I always use TIbScript for this (from IBX). I'm not sure what the script execute equivalent is for your db-style components (probably dbExpress seeing as you are using TSQLDataset).

     

    You could also put this code in a stored procedure (activate and inactivate) and call that if you need to call it more often.

    (you can call a stored procedure with ExecSQL if you set the commandtype to ctStoredProc.)

     


  10. Was this still possible in the latest Interbase version???

     

    For Firebird 3+ at least, directly updating the RDB$TRIGGERS isn't allowed anymore.

    See the comment here: https://gist.github.com/martinusso/1278962/07650568e3e71cb369dba68562a1e69e7fc4ba33

     

    You could try the EXECUTE BLOCK mentioned there. (I didn't test this)

    (Inactivating. Activating could be done similarly)

     

    SET TERM ^ ;
    EXECUTE BLOCK AS
    DECLARE VARIABLE NOMTABLE varchar(100);
    DECLARE VARIABLE REQ1 Varchar(100);
    BEGIN
      for select x.RDB$TRIGGER_NAME from rdb$triggers x where
        rdb$trigger_source is not null and (coalesce(rdb$system_flag,0) = 0)
        and rdb$trigger_source not starting with 'CHECK' into :NOMTABLE
      do
      begin
        NOMTABLE=trim(NOMTABLE);
        req1= 'ALTER TRIGGER ' || :NOMTABLE || ' INACTIVE;';
        execute statement req1;
      end
    END^
    SET TERM ; ^

     


  11. I just tested your messsage.txt and it works for me. I can create a draft with that message but I can also directly send it (because I have both draft and send access in my app approval).


    This is my code. (Although I would remove the headers From, Reply-To and Date because those would be added automatically. It doesn't hurt when you add them but they are NOT used. From is always the address of the default sender in gmail and Reply-To is always the gmail account and Date is always now.)

     

    Quote

     

          Url := 'https://www.googleapis.com/upload/gmail/v1/users/' + gOAuth2.email + '/messages/send';
          Response := TStringList.Create;
          HTTP := THTTPSend.Create;
          try
            // WorkStr := CreatePlainEML;
            WorkStr := TFile.ReadAllText('C:\Temp\messsage.txt');

            WriteStrToStream(HTTP.Document, ansistring(WorkStr));

            json := nil;

            HTTP.MimeType := 'message/rfc822';
            HTTP.Headers.Clear;
            HTTP.Headers.Add('Authorization: Bearer ' + gOAuth2.access_token);
            HTTP.Headers.Add('Accept: application/json');
            if HTTP.HTTPMethod('POST', Url) then
            begin
              Response.LoadFromStream(HTTP.Document);
              if HTTP.ResultCode <> 200 then
                  ShowMessage(Response.Text)
              else
              begin
                Result := SUCCESS_SUCCESS;
              end;
            end;

          finally
            HTTP.Free;
            Response.Free;
          end;

     

     

    Looking at your code I now do see a difference with my code.

    You are using Url := 'https://gmail.googleapis.com/gmail/v1/users/' + emailFrom + '/messages/send';

    I'm using Url := 'https://www.googleapis.com/upload/gmail/v1/users/' + gOAuth2.email + '/messages/send';

     

    You need to use the Upload URI, for media upload requests to post this as raw message.

    See here https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send

    There is a difference with /gmail/v1 and /upload/gmail/v1.

     

    If I use your Url I also get an invalid JSON error message 400.

    So use the other Url and it should be fine.

     


  12. Btw. It's best you first try a very simple rfc822 style message without attachment. If that works you can debug why adding attachments doesn't work.

     

    You can post the simple message here if it doesn't work for you so we can debug it. (i.e. wrong headers due to not disabling escaping mail adresses)

     

     


  13. 1 minute ago, JLG said:

    I tried adding the header accept json and mmime type as suggested, but to no avail...

    Can you post the raw rfc822 data in a txt file here with a simple testmail? (Did you try the overloaded saveto helper to disable escaping email adresses as suggested??)

     

    I can try it here to see what goes wrong.

    The rfc822 mimetype should work with send-api too (i thought).

     

    I also found that the error messages you get are indeed often unhelpfull (just a 4xx rejected without reason).

     

    Another option is just plain smtp with a specific app-password. But that's something each user should set in their own account (and provide your app with that password). Using the authetication method is much easier. Downside is that your app needs to go through the approval process of Google for the specified access.

     


  14. For posting a draft message to GMail I don't need any JSON. I can just post the complete mail (eml-format) to https://www.googleapis.com/upload/gmail/v1/users/<email-adres>/drafts. You do need to set the header Authorization: Bearer with the correct access_token.

     

    Ps. My MimeType (with Synapse) is message/rfc822 and accept is application/json. I don't see that in your code.

     

    Small snippet from my code (as I said with Synapse).

    Quote

    Url := 'https://www.googleapis.com/upload/gmail/v1/users/' + gOAuth2.email + '/drafts';
    WorkStr := CreatePlainEML;
    WriteStrToStream(HTTP.Document, ansistring(WorkStr));
    HTTP.MimeType := 'message/rfc822';
    HTTP.Headers.Clear;
    HTTP.Headers.Add('Authorization: Bearer ' + gOAuth2.access_token);
    HTTP.Headers.Add('Accept: application/json');
    if HTTP.HTTPMethod('POST', Url) then
    begin
      Response.LoadFromStream(HTTP.Document);
      if HTTP.ResultCode <> 200 then
        ShowMessage(Response.Text)
      else
      begin
        obj := SO(Response.Text);
        Url := 'https://mail.google.com/mail?authuser=' + gOAuth2.email + '#drafts/' + urlencode(obj.S['message.id']);
        BrowseURL(Url);
        Result := SUCCESS_SUCCESS;
      end;
    end;

    The CreatePlainEML creates a mail message which is compatible with Outlook Express and Thunderbird (I believe this is the rfc822 e-mail standard).

    With TMimemess and multiple TMimepart parts followed by the TMememess.EncodeMessage-function from Synapse.

     

    So there shouldn't be any need for posting JSON (only retrieving the result as JSON).

    I don't think TIdMessage creates a much different text but I'm not sure.

     

    • Like 1
×