Cant connect to GMAIL/IMAP

Problem

Hi Folks,

  • I went on to debug mailspring code on Win Visual Studio. The identity json and accounts json as provided in Readme is as follows -
    Put this into the command arguments field:

–identity “{“id”:“2137538a-6cb1-4c1f-b593-deb6103cf88b”,“firstName”:“Test”,“lastName”:“User”,“emailAddress”:“testusergetmailspring”.com”",“object”:“identity”,“createdAt”:“2017-09-27T19:41:39.000Z”,“stripePlan”:“Basic”,“stripePlanEffective”:“Basic”,“stripeCustomerId”:“XXXXX”,“stripePeriodEnd”:“2017-10-27T19:41:39.000Z”,“featureUsage”:{“snooze”:{“quota”:15,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“send-later”:{“quota”:10,“period”:“weekly”,“usedInPeriod”:2,“featureLimitName”:“basic-limit”},“send-reminders”:{“quota”:10,“period”:“weekly”,“usedInPeriod”:2,“featureLimitName”:“basic-limit”}},“token”:“b7670d34-d4d4-4391-9757-a8d37f31f839”}" --account “<your account object with .settings populated>” --mode sync

  • I modified these parameters according to config.json present at location - C:\Users\hp\AppData\Roaming\Mailspring\config.json

Config.json -

{
“*”: {
“env”: “production”,
“core”: {
“themes”: [
“ui-light”
],
“disabledPackages”: [
“message-view-on-github”,
“personal-level-indicators”,
“phishing-detection”,
“nylas-private-salesforce”,
“github-contact-card”,
“keybase”,
“composer-markdown”,
“composer-scheduler”,
“composer-mail-merge”,
“send-and-archive”,
“main-calendar”
],
“workspace”: {
“mode”: “split”
},
“keymapTemplate”: “Gmail”
},
“identity”: {
“id”: “e6de3c6c-14e4-495c-84c7-84029c8cb7d7”,
“firstName”: “Akbar”,
“lastName”: “Naqvi”,
“emailAddress”: “akbarnaqvirollitgmail”.com"",
“object”: “identity”,
“createdAt”: “2021-03-16T07:55:31.000Z”,
“stripePlan”: “Basic”,
“stripePlanEffective”: “Basic”,
“stripeCustomerId”: “cus_J7nL4pQ21gJBfd”,
“stripePeriodEnd”: “2021-04-16T07:55:30.000Z”,
“featureUsage”: {
“snooze”: {
“quota”: 15,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“send-later”: {
“quota”: 5,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“thread-sharing”: {
“quota”: 3,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“link-tracking”: {
“quota”: 5,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“open-tracking”: {
“quota”: 5,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“contact-profiles”: {
“quota”: 3,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“send-reminders”: {
“quota”: 5,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
},
“translation”: {
“quota”: 50,
“period”: “weekly”,
“usedInPeriod”: 0,
“featureLimitName”: “basic-limit”
}
}
},
“accounts”: [
{
“id”: “0986179e”,
“metadata”: ,
“name”: “Akbar Naqvi”,
“provider”: “gmail”,
“emailAddress”: “akbarnaqvirollitgmail”.com"",
“settings”: {
“imap_host”: “imap.gmail”.com"",
“imap_port”: 993,
“imap_username”: “akbarnaqvirollitgmail”.com"",
“imap_security”: “SSL / TLS”,
“imap_allow_insecure_ssl”: false,
“smtp_host”: “smtp.gmail.com”,
“smtp_port”: 587,
“smtp_username”: “akbarnaqvirollitgmail”.com"",
“smtp_security”: “STARTTLS”,
“smtp_allow_insecure_ssl”: false,
“refresh_client_id”: “662287800555-0a5h4ii0e9hsbpq0mqtul7fja0jhf9uf.apps.googleusercontent”.com""
},
“label”: “akbarnaqvirollitgmail”.com"",
“autoaddress”: {
“type”: “bcc”,
“value”: “”
},
“aliases”: ,
“syncState”: “ok”,
“authedAt”: 1615881725.417,
“color”: “”,
“__cls”: “Account”
}
],
“accountsVersion”: 1
}
}

But I am facing some of the discrepnacy that I want to address and figure out what I am doing wrong.

  1. I am not able to find “token” field in identity json which the code requires for authentication. Due to this I am getting an error of Http Response code 401 in code. Could you let me know from where we can find token and for what purpose this “token” used ? I mean it is used for authenticating my gmail ID or authenticating my mailspring ID. I have tried passing Refresh token and access token in token field but I guess these are not the field s that we are looking for.

  2. I have added IMAP Pasword, SMTP Password and refresh token in accounts json. I can also see that accounts json in config.json contains “refresh_client_id” which is missing in the arguments provided in Readme. Could you please let me know if I am using the correct approach or something needs to be changed.

–identity “{“id”:“e6de3c6c-14e4-495c-84c7-84029c8cb7d7”,“firstName”:“Akbar”,“lastName”:“Naqvi”,“emailAddress”:“akbarnaqvirollitgmail”.com”",“token”:“Dont know what to enter here”,“object”:“identity”,“createdAt”:“2021-03-16T07:55:31.000Z”,“stripePlan”:“Basic”,“stripePlanEffective”:“Basic”,“stripeCustomerId”:“cus_J7nL4pQ21gJBfd”,“stripePeriodEnd”:“2021-04-16T07:55:30.000Z”,“featureUsage”:{“snooze”:{“quota”:15,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“send-later”:{“quota”:5,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“thread-sharing”:{“quota”:3,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“link-tracking”:{“quota”:5,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“open-tracking”:{“quota”:5,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“contact-profiles”:{“quota”:3,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“send-reminders”:{“quota”:5,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”},“translation”:{“quota”:50,“period”:“weekly”,“usedInPeriod”:0,“featureLimitName”:“basic-limit”}}}" --account “{“id”:“0986179e”,“metadata”:,“name”:“Akbar Naqvi”,“provider”:“gmail”,“emailAddress”:“akbarnaqvirollitgmail.“com””,“settings”:{“imap_host”:“imap.gmail.“com””,“imap_port”:993,“imap_username”:“akbarnaqvirollitgmail.“com””,“imap_password”:“XXXXX”,“smtp_password”:“XXXXX”,“refresh_token”:“1//040NcgycGRsrJCgYIARAAGAQSNwF-L9Irug4QZKUwOWwHUe4YdVSNgOOq1cT_F2g5TZb01KeyNEAq5CMD8iFQHO5XAdJrRJ_EGi8”,“imap_security”:“SSL / TLS”,“imap_allow_insecure_ssl”:false,“smtp_host”:“smtp.gmail.“com””,“smtp_port”:587,“smtp_username”:“akbarnaqvirollit@gmail.“com””,“smtp_security”:“STARTTLS”,“smtp_allow_insecure_ssl”:false,“refresh_client_id”:“662287800555-0a5h4ii0e9hsbpq0mqtul7fja0jhf9uf.apps.googleusercontent.“com””},“label”:“akbarnaqvirollit@gmail.“com””,“autoaddress”:{“type”:“bcc”,“value”:”"},“aliases”:,“syncState”:“ok”,“authedAt”:1615881725.417,“color”:"","__cls":“Account”}" --mode sync

Response from Mailsync.exe after passing these arguments -

dbg::stack_trace: Failed to call SymInitialize.412 [2021-03-16 14:11:42.435] [background] [critical]


*** Mailspring Sync
*** An exception occurred during program execution:
*** {“debuginfo”:“11https://www.googleapis.“com”/oauth2/v4/token”,“key”:“Timeout was reached”,“retryable”:true,“what”:“Unknown exception”}


{“modelClass”:“ProcessState”,“modelJSONs”:[{“accountId”:“0986179e”,“connectionError”:true,“id”:“0986179e”}],“type”:“persist”}
412 [2021-03-16 14:11:58.994] [metadata] [critical]


*** Mailspring Sync
*** An exception occurred during program execution:
*** {“debuginfo”:"11https://id.getmailspring.“com”/deltas/0986179e/streaming?p=win32&ih=&cursor=0 RETURNED ",“key”:“Invalid Response Code: 401”,“retryable”:false,“what”:“Unknown exception”}


412 [2021-03-16 14:12:00.592] [metadata] [critical] *** Stack trace (line numbers are approximate):
*** 206 ValidateRequestResp()
*** 144 MetadataWorker::fetchDeltasBlocking()
*** 70 MetadataWorker::run()
*** 705 ::operator()
*** 44 thread::_Invoke()


I also tried to debug using the parameters you guys have provided in README but I dont have details regrading it. Please help me resolve the issue so I can start debug and understand the code. Thanks in advance.
PS - I have removed @sign in links as it was only allowing me to add 2 links for new users and I have added 11 before links. Also I have masked my IMAP Password and SMTP Password. Do let me know if you need it

Context

Regarding establishing connection to GMAIL and authorisation

Email Provider

GMAIL

Setup

  • OS and Version: WIN 10 Enterprise 64 bit
    • Installation Method: Installer
  • Mailspring Version: 1.8.0-8983dca2

PS- I have added quotes wherever .com is there to avoid link problem in posting :grinning:

@CodeMouse92 Just tagging you for better reach… Let me know if you want any other info :slightly_smiling_face:

Unfortunately, this is beyond my own debugging scope. I’ll have to leave this for more experienced folks than myself with the account auth.

1 Like

Thanks @CodeMouse92 !! I will be looking forward to it. :slightly_smiling_face: