Jump to content

marcin

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. marcin

    Indy IMAP and Microsoft EWS

    Now I'm totally confused. Getting back to square one and starting from very beginning...
  2. marcin

    Indy IMAP and Microsoft EWS

    @polasss You mean procedure for obtaing a token? Yest it works, I get "200" with JSON containing access_token
  3. marcin

    Indy IMAP and Microsoft EWS

    Remy I'm obtaining the access_token the way you helped me in another thread: scope := 'https://graph.microsoft.com/.default'; msUrl := 'https://login.microsoftonline.com/%s/oauth2/v2.0/token'; sslHandler := TIdSSLIOHandlerSocketOpenSSL.Create; sslHandler.SSLOptions.Method := sslvTLSv1_2; sslHandler.SSLOptions.SSLVersions := [sslvTLSv1_2]; httpClient := TIdHTTP.Create; httpClient.HTTPOptions := [hoForceEncodeParams, hoNoProtocolErrorException, hoWantProtocolErrorContent]; httpClient.IOHandler := sslHandler; httpClient.Request.ContentType := 'application/x-www-form-urlencoded'; tsRequestBody := TStringList.Create; tsRequestBody.Add('grant_type=client_credentials'); tsRequestBody.Add('client_id=' + ClientID); tsRequestBody.Add('client_secret=' + ClientSecret); tsRequestBody.Add('scope=' + scope); sResponse := httpClient.Post(Format(msUrl, [TenantID]), tsRequestBody); responseCode := httpClient.ResponseCode; if responseCode = 200 then begin jsonOject := TJSONObject.ParseJSONValue(sResponse) as TJSONObject; jsonValue := jsonOject.Values['access_token']; accessToken := jsonValue.ToString; Result := True; end else begin Result := False; accessToken := sResponse; end; TIA Marcin
  4. marcin

    Indy IMAP and Microsoft EWS

    Hi Since Office 365 account I'm trying to connect to with TIdIMAP4 does not support App-specific password, I have to use TIdSASLXOAuth2 from ssl-oauth branch. I have managed to obtain access token from login.microsoftonline.com, but I'm getting 'Authentication failed' when trying to log in to IMAP. How can I check (if possible) if there is something wrong with the token (i.e incorrect scope) or TIdSASLXOAuth2 itself requires some tweaking? Or maybe there is something wrong with my code: sslHandler := TIdSSLIOHandlerSocketOpenSSL.Create; sslHandler.SSLOptions.Method := sslvTLSv1_2; sslHandler.SSLOptions.SSLVersions := [sslvTLSv1_2]; IMAP := TIdIMAP4.Create(Self); IMAP.IOHandler := sslHandler; IMAP.UseTLS := utUseImplicitTLS; IMAP.Host := 'outlook.office365.com'; IMAP.Port := 993; IMAP.OnStatus := IdIMAP41Status; xoauthSASL := IMAP.SASLMechanisms.Add; xoauthSASL.SASL := TIdSASLXOAuth2.Create(nil); TIdSASLXOAuth2(xoauthSASL.SASL).UserPassProvider := TIdUserPassProvider.Create(); TIdSASLXOAuth2(xoauthSASL.SASL).UserPassProvider.Username := microsoft_clientaccount; TIdSASLXOAuth2(xoauthSASL.SASL).UserPassProvider.Password := AccessToken; IMAP.AuthType := iatSASL; IMAP.Connect(True); Can someone help? TIA Marcin
  5. @Remy Lebeau You are the (rock) star 😃, thank you so much It looks like looong learning path ahead of me
  6. Last version is: StringWriter := TStringWriter.Create(); Writer := TJsonTextWriter.Create(StringWriter); Writer.Formatting := TJsonFormatting.Indented; Writer.WriteStartObject; Writer.WritePropertyName('grant_type'); Writer.WriteValue('client_credentials'); Writer.WritePropertyName('client_id'); Writer.WriteValue(ClientID); Writer.WritePropertyName('client_secret'); Writer.WriteValue(ClientSecret); Writer.WritePropertyName('scope'); Writer.WriteValue('https://graph.microsoft.com/.default'); Writer.WriteEndObject; requestBody := TStringStream.Create(StringWriter.ToString, TEncoding.UTF8); requestBody.Position := 0; and presented JSON comes from: TStringStream(RequestBody).DataString
  7. Hi Guys I need a little help here I'm trying to send following JSON to https://login.microsoftonline.com/ { "grant_type": "client_credentials", "client_id": "xxx", "client_secret": "_xxx_", "scope": "https://graph.microsoft.com/.default" } using following code: IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded'; url := 'https://login.microsoftonline.com/' + TenantID + '/oauth2/v2.0/token'; FLastResult := IdHTTP.Post (url, requestBody); where requestBody is a TStream containing the string with the JSON. I got "400" error response from microsoft saying that "The request body must contain the following parameter: 'grant_type'" Apparently I'm missing something here, since I've tested this with Postman I there I get proper response containing requested token. Any clues? TIA Marcin
  8. marcin

    Indy IMAP and Microsoft EWS

    Remy Thanks for the answers, following your suggestion, first I'll try with App-specific password. Marcin
  9. marcin

    Indy IMAP and Microsoft EWS

    Hi Is Indy IMAP component capable to connect to Office 365 account? How "mature" is Indy ssl-oauth branch? I'm looking for some solution to only read 'unread' emails from this account, mark them as 'read' and optionally copy them to another folder TIA Marcin
  10. marcin

    Q for MAPI Expert

    @Attila Kovacs Thanks a lot for promtp response I have tested with my email app - I use eM Client - and it did not work, but I will check tomorrow on other workstation. I need it working just with thunderbird. Marcin
  11. marcin

    Q for MAPI Expert

    @Attila Kovacs Thanks for sharing the unit - it works in environments where other solutions have failed. I'd like to ask if it possible to prepare body of the message as html. I've read the unit couple of times, but I have not found the way. TIA Marcin
  12. marcin

    Q for MAPI Expert

    Hi Is there a place where latest version of the unit is available? I'm facing similar issues on newer windows 10 machines where attemp of sending a message via MAPI return MAPI error. Old machines with updated Win10 work perfectly. Thanks in advance Merry Christmas / Happy Holidays M.
  13. Hi Guys I have serious problem with my FMX application compiled with Delphi Rio and run on Android 5.1. The case is that when I place TEdit and TStringGrid on the same form - application freezes. When both are on the main form, application even won't start. There is no problem if I compile same sources with Delphi Tokyo. Has anybody experienced something like this? I'd appreciate any possible solutions other that getting rid of the grid (than it works) TIA Marcin
×