Comments (8)
If the code has entered fetch_token_from_cache
, then it has found the credentials file and loaded it. It seems like the credentials file might be corrupted. Could you dump the accounts variable here? Also the result variable here? It will help with debugging.
Please use pp.pprint(...)
to dump the variables.
from oauth2ms.
Thanks for the response. I added pp.print(accounts)
and pp.print(result)
and this was the output (with some changes to the ids):
[ { 'authority_type': 'MSSTS',
'environment': 'login.microsoftonline.com',
'home_account_id': '1a0b0b01-e0a3-4f97-9d7f-4a2908607c6a.d54d65af-91e2-44b4-b9cb-0gg38e55eb41',
'local_account_id': 'e9181b38-8eb4-4398-8ed2-761dd1830400',
'realm': 'ca6554cd-1d6c-4328-98ee-84214b1a7d9c',
'username': '<email-address>'}]
None
Traceback (most recent call last):
File "~/.local/bin/oauth2ms", line 249, in <module>
token = fetch_token_from_cache(app_state)
File "~/.local/bin/oauth2ms", line 183, in fetch_token_from_cache
return result["access_token"]
TypeError: 'NoneType' object is not subscriptable
from oauth2ms.
The accounts output looks okay. It is possible that the token cache is corrupted. Could you try deleting the file in $XDG_DATA_HOME/share/oauth2ms/credentials.bin
and trying again?
from oauth2ms.
That seems to have done the trick for the TypeError, but it is still not properly authenticating. Running mbsync -Dna
gets me:
Reading configuration file ~/.mbsyncrc
Channel <channel-name>
Opening master store <master-store-name>...
Resolving outlook.office365.com... ok
Connecting to outlook.office365.com (40.100.146.18:143)...
Opening slave store <slave-store-name>...
* OK The Microsoft Exchange IMAP4 service is ready. [UfB.....AG4]
>>> 1 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
1 OK CAPABILITY completed.
>>> 2 STARTTLS
2 OK Begin TLS negotiation now.
Connection is now encrypted
>>> 3 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
3 OK CAPABILITY completed.
Logging in...
Authenticating with SASL mechanism XOAUTH2...
>>> 4 AUTHENTICATE XOAUTH2 dRN.....ALQ
4 NO AUTHENTICATE failed.
IMAP command 'AUTHENTICATE XOAUTH2 dRN.....ALQ' returned an error: NO AUTHENTICATE failed.
I guess this is not a problem with oauth2ms
. Perhaps I didn't correctly install cyrus-sasl-xoauth2
. What do you think?
from oauth2ms.
Few things to remember/try:
- Don't use
--encode-xoauth2
in the mbsyncrc - In
AUTHENTICATE XOAUTH2 dRN.....ALQ
check that thedRN.....ALQ
part matches the output fromoauth2ms --encode-xoauth2
- run
echo dRN.....ALQ | base64 -d
and copy the output after auth=Bearer and paste it in https://jwt.ms. Check if there are any mistakes in email, client or other details.
from oauth2ms.
Everything seems ok. If the issue is not with cyrus-sasl-xoauth2
it might be related to how I set up the Azure application. I was unable to access Azure active directory with my work email, so used a personal email address. This lead to me setting up a tenant and adding my work email as a user, and then creating the application from there.
Do you have any suggestions for how to resolve this? I am determined to get this working, but am aware this has strayed beyond your code.
from oauth2ms.
AFAIK, fetching and sending emails is tied to the client, tenant, and application. All these three must be part of the same org for it to work. I am not sure if creating a separate tenant will permit you to access mailboxes that are part of the other tenant.
I think the best option here is to ask your organization to enable azure portal access.
That said, if you find a solution using this method, please do open a PR to update the docs :)
from oauth2ms.
Thanks for your help. I will see if I can get them to enable Azure for the account.
from oauth2ms.
Related Issues (20)
- issue during setup after authentication HOT 14
- How to setup SMTP if one knows the access token already? HOT 6
- device code flow
- Support writing to/reading from keyring
- urllib3.exceptions.LocationParseError: Failed to parse HOT 1
- Problem configuring URLs for Office365 HOT 3
- Alternative to obtain tenant ID and client ID and secret HOT 6
- "AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented. HOT 1
- NO AUTHENTICATE HOT 6
- Sending failed SMTPclient is disabled for the tenant HOT 2
- Adding smtp after using oauth2 for imap HOT 3
- O365 Authentication Issues HOT 3
- Using a public id HOT 2
- TypeError: 'NoneType' object is not subscriptable HOT 2
- mbsync IMAP command 'NAMESPACE' returned an error: BAD User is authenticated but not connected. HOT 3
- Mac install HOT 1
- Sending Emails Fails HOT 4
- Multi-account support implementation HOT 8
- Token Returned, Authentication Error in mbsync HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oauth2ms.