500 error when connect with Microsoft 365

Infos:

  • Used Zammad version: 5.2.x
  • Used Zammad installation type: Package
  • Operating system: Linux (ubuntu 20.04) / Apache with SSL (certbot)
  • Browser + version: Chrome 106.0.5249.61 64 bits and Firefox 105.0.1 (64-bits)

Expected behavior:

  • Need to use OAuth authentication because basic authentication will be discontinued soon (Microsoft 365)

Actual behavior:

  • I followed the documentation, created the application registration, gave the necessary permissions and also configured the Callback URL.
    However, when enter “Channels” - “Microsoft 365” - “Add Account”, after the consent, I get "class=“error-message”<% end %>> 500: We’re sorry, but something went wrong. <% if !@traceback %>

Steps to reproduce the behavior:

  • “Channels” - “Microsoft 365” - “Add Account”

Here is the production.log in the exact moment of error:

I, [2022-09-30T16:36:46.783952 #696-115260] INFO – : execute Ticket.process_escalation (try_count 0)…
I, [2022-09-30T16:36:46.785485 #696-115260] INFO – : ended Ticket.process_escalation took: 0.009597377 seconds.
I, [2022-09-30T16:36:48.063195 #696-109160] INFO – : execute Channel.fetch (try_count 0)…
I, [2022-09-30T16:36:48.064931 #696-109160] INFO – : fetching imap (Sign in to Outlook port=993,ssl=true,starttls=false,folder=INBOX,keep_on_server=true,auth_type=LOGIN)
I, [2022-09-30T16:36:48.441305 #691-644020] INFO – : Started GET “/api/v1/external_credentials/microsoft365/callback?code=[FILTERED]&session_state=88f2ea24-1fb7-4a8e-aa75-f7c670c9c6f0” for 131.196.77.189 at 2022-09-30 16:36:48 +0000
I, [2022-09-30T16:36:48.446452 #691-644020] INFO – : Processing by ExternalCredentialsController#callback as HTML
I, [2022-09-30T16:36:48.446517 #691-644020] INFO – : Parameters: {“code”=>“[FILTERED]”, “session_state”=>“88f2ea24-1fb7-4a8e-aa75-f7c670c9c6f0”, “provider”=>“microsoft365”}
I, [2022-09-30T16:36:48.466721 #696-109160] INFO – : - no message
I, [2022-09-30T16:36:48.479146 #696-109160] INFO – : ended Channel.fetch took: 0.426276704 seconds.
E, [2022-09-30T16:36:48.802189 #691-644020] ERROR – : 859: unexpected token at ‘{“aud”:“7d9b4b58-59f6-42f3-b96e-396c85ce7ee5”,“iss”:"https://login.microsoftonline.com/50e3305f-3a03-4d95-962c-d33e904692ec/v2.0",“iat”:1664555508,“nbf”:1664555508,“exp”:1664559408,“email”:“patrick@mydomain.com”,“name”:"Patrick Roberto ▒#▒▒▒▒▒▒▒▒
YY
KX▒NMKM
XY▒
▒▒ N
▒▒L▒X▒▒Y▒\▒▒Y▒\▒\▒▒[YH▒▒▒]▒X▒▒▒▒X˘▒▒K▒▒▒▒▒▒▒
X▒VٝU[SM ▒T▒PV▒▒PSM▒L▒▒▒KZ▒XT▒њ▒ٓ̕▒▒U▒
▒▒▒X▒▒▒▒٘▒Lі▒▒▒UГ[▒▒P[N▒▒
Q▒^▒▒▒▒▒
Y▒L▒L▒▒▒LL▒▒
▒MMKNM▒▒▒Y
▒L▒X▒]H▒▒▒ܜ▒N^▒▒▒Y▒▒^S▒▒▒PPH▒▒\▒▒▒▒▒▒’ (JSON::ParserError)
lib/external_credential/microsoft365.rb:268:in `user_info’
lib/external_credential/microsoft365.rb:47:in `link_account’
app/models/external_credential.rb:21:in `link_account’
app/controllers/external_credentials_controller.rb:43:in `callback’
app/controllers/application_controller/has_download.rb:21:in `block (4 levels) in module:HasDownload
app/controllers/application_controller/has_download.rb:20:in `block (3 levels) in module:HasDownload
app/controllers/application_controller/has_download.rb:19:in `block (2 levels) in module:HasDownload
app/controllers/application_controller/handles_transitions.rb:16:in `handle_transaction’
I, [2022-09-30T16:36:48.803386 #691-644020] INFO – : Completed 500 Internal Server Error in 357ms (ActiveRecord: 1.1ms | Allocations: 6805)
F, [2022-09-30T16:36:48.803909 #691-644020] FATAL – :
[d8980ce2-160e-40d5-89d2-544ae056288a] ArgumentError (invalid byte sequence in UTF-8):
[d8980ce2-160e-40d5-89d2-544ae056288a]
[d8980ce2-160e-40d5-89d2-544ae056288a] app/controllers/application_controller/handles_errors.rb:97:in `match?’
[d8980ce2-160e-40d5-89d2-544ae056288a] app/controllers/application_controller/handles_errors.rb:97:in `humanize_error’
[d8980ce2-160e-40d5-89d2-544ae056288a] app/controllers/application_controller/handles_errors.rb:77:in `block (2 levels) in respond_to_exception’
[d8980ce2-160e-40d5-89d2-544ae056288a] app/controllers/application_controller/handles_errors.rb:74:in `respond_to_exception’
[d8980ce2-160e-40d5-89d2-544ae056288a] app/controllers/application_controller/handles_errors.rb:34:in `internal_server_error’

any help is appreciated

Do you use a Reverse Proxy?

Same exact setup - same issue, following this thread hoping someone replies with a solution.

Hi Bur,
Not using Reverse Proxy.
Running only 1 VM and publish 80/443 port.

Does your users has special characters ?
for example: my exibition name in M365 is “Patrick :cloud:” (with a cloud character) … could it be affect maybe ?

So I checked my configuration again, and discovered that for the shared secret (in Azure > App Registrations > Zammad> Certificates and secrets) I had copied the “Secret ID” into Zammad when setting up the Microsoft 365 channel instead of the “Value”.

Since you can’t view the value except right after creating the secret, I deleted the secret in M365 and created a new one, then copied the “value” into Zammad.

After that I didn’t get the 500 error.

So, my error.

1 Like

Hello guys,

It´s working now.
The problem was the display name character. We have a cloud symbol (:cloud:) at display name. After I removed it, it worked fine…

Maybe in newer versions the develop team includes support for these special characters.

Thank you all and have a good week!

You don’t happen to use MariaDB / MySQL, do you?

I´m using MariaDB / MySQL. Is it the problem ?

Absolutely.
https://docs.zammad.org/en/latest/prerequisites/software.html#database-server

1 Like

Thank You MrGeneration !

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.