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

Feat: Support for Microsoft Oauth in Email Channel #6227

Merged
merged 51 commits into from
Jan 16, 2023

Conversation

tejaswinichile
Copy link
Contributor

@netlify
Copy link

netlify bot commented Jan 10, 2023

Deploy Preview for chatwoot-storybook ready!

Name Link
🔨 Latest commit 759fecf
🔍 Latest deploy log https://app.netlify.com/sites/chatwoot-storybook/deploys/63c5b9d244e1a900099fa50d
😎 Deploy Preview https://deploy-preview-6227--chatwoot-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.


@response = client.auth_code.get_token(
oauth_code,
redirect_uri: "#{base_utl}/microsoft/callback"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
redirect_uri: "#{base_utl}/microsoft/callback"
redirect_uri: "#{base_url}/microsoft/callback"

inbox = create_inbox
::Redis::Alfred.delete(permitted_params['current_account_id'])
# ::microsoft::WebhookSubscribeService.new(inbox_id: inbox.id).perform
redirect_to app_twitter_inbox_agents_url(account_id: account.id, inbox_id: inbox.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us rename this path.

@@ -249,6 +249,8 @@ GEM
gli (2.21.0)
globalid (1.0.0)
activesupport (>= 5.0)
gmail_xoauth (0.4.2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tejaswinichile net::imap latest versions support xoauth automatically. We can upgrade the package. No need to do it in this PR. We can take it as a separate task.

Copy link
Member

@pranavrajs pranavrajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to "request changes" status so that we don't accidently merge this PR.

.env.example Outdated
#MS OAUTH creds
AZURE_APP_ID=
AZURE_APP_SECRET=
AZURE_SCOPES = 'Mail.Send offline_access https://graph.microsoft.com/IMAP.AccessAsUser.All https://graph.microsoft.com/SMTP.Send'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tejaswinichile Why do we need to take this as an env variable?

Comment on lines 10 to 17
def perform
Channel::Email.where(provider: 'microsoft').each do |channel|
# refresh the token here, with microsoft offline_access scope
provider_config = channel.provider_config || {}

refresh_tokens(channel, provider_config.with_indifferent_access) if provider_config[:refresh_token].present?
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this to services instead. since we won't be using the perform block nor need to inherit the application job. We only need the access_token method, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! makes sense 👍🏼

@sojan-official sojan-official changed the title Feat: Microsoft Oauth Api/s Feat: Support for Microsoft Oauth in Email Channel Jan 13, 2023
Copy link
Member

@sojan-official sojan-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • refactored the refresh token service a bit and added some addition specs.
  • noted that specs for callbacks controller is missing

@@ -53,6 +53,10 @@
"ENABLE": "Create conversations from mentioned Tweets"
}
},
"MICROSOFT": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a part of the frontend PR ?

@sojan-official sojan-official merged commit 00cbdaa into develop Jan 16, 2023
@sojan-official sojan-official deleted the feat/microsoft-oauth-apis branch January 16, 2023 21:09
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants