Giter Club home page Giter Club logo

Comments (8)

harishkrupo avatar harishkrupo commented on May 29, 2024

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.

jimmerricks avatar jimmerricks commented on May 29, 2024

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.

harishkrupo avatar harishkrupo commented on May 29, 2024

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.

jimmerricks avatar jimmerricks commented on May 29, 2024

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.

harishkrupo avatar harishkrupo commented on May 29, 2024

Few things to remember/try:

  1. Don't use --encode-xoauth2 in the mbsyncrc
  2. In AUTHENTICATE XOAUTH2 dRN.....ALQ check that the dRN.....ALQ part matches the output from oauth2ms --encode-xoauth2
  3. 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.

jimmerricks avatar jimmerricks commented on May 29, 2024

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.

harishkrupo avatar harishkrupo commented on May 29, 2024

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.

jimmerricks avatar jimmerricks commented on May 29, 2024

Thanks for your help. I will see if I can get them to enable Azure for the account.

from oauth2ms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.