Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Handling 'MailboxNotEnabledForRESTAPI' made more difficult #12

Open
pruggiero opened this issue Sep 12, 2018 · 1 comment
Open

Comments

@pruggiero
Copy link

I'm struggling with the below sections of code from the lib/strategy.js

    /* Specific case where a user creates a new Outlook account via the OAuth screen
     * and the redirect back to the application bypasses M$'s account finalisation
     * process, giving you an Outlook account with no Mailbox entry.
     */
    if (res && res.statusCode === 404) {
        return done(new OutlookAPIError(res.headers['x-caserrorcode'], res.statusCode));
    }

This code catches multiple scenario's like when the account has no mailbox or the account's office license has expired, its a fairly common issue. I want to be able to handle this error in specific ways and direct the user to use another provider given they can't use the Outlook API or at least provide information of possible causes.

Since this is catching the error and not using my verify callback, it makes handling this case more difficult. I was thinking of opening a PR that sets a flag to bypass this check, but I really think this error should be dealt with in the verify callback and this code should just be removed. Without it being there all that occurs is we get a bad profile, which is a possibility that I already need to handle. It just feels like this section of code covers too many possible failure cases.

Curious if others have encountered similar issues.

@clocked0ne
Copy link
Owner

A strategy really should not be making decisions based on responses, that has to be down to the individual developer / business logic. That said, I have had to handle the scenario where the user has no Mailbox, just an MS account (or it is not yet enable for the REST API) and it was easily identified in the 'bad' profile. As our service also offers GMail support we could offer this as an alternative, but not everyone using this library will be of the same circumstances or opinion of how it should be handled.

It would be interesting to hear from the wider community using this if they have faced similar issues; I would welcome non-breaking creative suggestions on means of handling these responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants