Difference between revisions of "Oauth2"

From Claws Mail FAQ
Jump to navigationJump to search
m (Protected "Oauth2" ([Move=Allow only administrators] (indefinite)))
(→‎Setting up OAuth 2.0 for Gmail: (Corrected Google account sign-in information.) (Improved information on project publishing status.) →‎Setting up OAuth 2.0 for Microsoft...: (Re-worked and expanded content.))
Line 17: Line 17:
 
https://support.google.com/googleapi/answer/6158849
 
https://support.google.com/googleapi/answer/6158849
  
Note: Before starting, make sure that you are not logged in (via webmail) to any Gmail account, or that you are logged in to only the relevant account.
+
Note: If you use more than one Google/Gmail account, make sure you are signed in to Google Cloud Platform with the desired account before creating a project or changing any settings. (It is possible to be signed into multiple accounts; just make sure the browser tab/window you are working in is controlled by the correct account.)
  
 
When setting up the project use these settings:
 
When setting up the project use these settings:
 
<pre>  Project name: Anything of your choice
 
<pre>  Project name: Anything of your choice
  
   Publishing status (of project): 'Testing' (initial default)
+
   Publishing status (of project): 'In Production'
  
 
   User type: External
 
   User type: External
Line 32: Line 32:
 
2. Regarding Google's above-linked instructions related to the "Credentials" page: Where it says "Click 'New Credentials'" it should read "Click '+ CREATE CREDENTIALS'" (as of 24 Mar 2022).
 
2. Regarding Google's above-linked instructions related to the "Credentials" page: Where it says "Click 'New Credentials'" it should read "Click '+ CREATE CREDENTIALS'" (as of 24 Mar 2022).
  
3. Regarding "Publishing status", there isn't an option to choose this when you are creating a new project. It seems that the status will be considered as 'Testing' unless/until you have clicked on 'Publish App' in the 'Publishing status' section of the 'OAuth Consent Screen'; then it will be considered as being 'In Production'. (However, 'publishing' the app may require that it be submitted to Google for verification, which requires a variety of submissions that seem more relevant to the developers of an app for 'everyone' rather than for a user who is trying to set something up for themselves.) It is possible to get it working by using the 'Testing' status if you add the relevant email address to the 'Test Users' list on the 'Edit App Registration' - 'Test Users' page of the 'OAuth Consent Screen' setup process (or on the main 'OAuth Consent Screen' page). However, authorization with this status may only last for seven days. (As of 24 Mar 2022.)
+
3. Regarding "Publishing status", the initial default is 'Testing'. To change this to 'In Production' click on the 'Publish App' button in the 'Publishing status' section of the 'OAuth Consent Screen', and then click on 'Confirm'. This results in the status changing to ‘In Production’ and a new section ‘Verification Status’ showing with a ‘Needs verification’ status, which can be safely ignored. If this doesn't work for some reason, you can switch back to 'Testing' status on the same 'OAuth Consent Screen' page you used before. For this status to work you need to make sure you've added the desired email address to the 'Test Users' list on the 'Edit App Registration' - 'Test Users' page of the 'OAuth Consent Screen' setup process (or on the main 'OAuth Consent Screen' page). Note that with this status each authorization code will only last for seven days, after which you will be unable to connect and will see authorization errors in the network log. To get a new authorization code, go to the 'OAuth2' page of the Claws Mail settings and repeat the steps for getting an authorization code and completing authorization. (Note that there is no need to get a new client ID or client secret.) (as of 17 Apr 2022)
  
  
Line 59: Line 59:
 
   Click on 'Save and Continue'.
 
   Click on 'Save and Continue'.
 
</pre>
 
</pre>
'''Getting the ClientID'''
+
'''Getting the Client ID'''
 
<pre>
 
<pre>
 
   APIs and Services on the left menu, then Credentials entry
 
   APIs and Services on the left menu, then Credentials entry
  
   Copy the ClientID to the custom entry box on Claws Mail Oauth2 account preferences screen.
+
   Copy the Client ID to the corresponding field on Claws Mail's account settings' 'Oauth2' page.
  
   Select "Edit Oauth Credentials" (pencil icon), then copy the Client Secret to the entry in
+
   Select "Edit OAuth Credentials" (pencil icon), then copy the Client Secret to the corresponding field on Claws Mail's account settings' 'Oauth2' page.
  Claws Mail Oauth2 account preferences screen.
 
 
</pre>
 
</pre>
 
'''Troubleshooting:'''
 
'''Troubleshooting:'''
  
 
It's possible / probable that Gmail will 'complain' about giving access to an unverified third-party app. If this keeps you from using Claws to access your Gmail, you may need to log in to Gmail's web-mail interface and review / revise your security settings there. This may involve dismissing the warning Google gives about the Project that you set up for Claws to access GMail on your account. If you dismiss a Warning, Google may then ask you why you are dismissing it, providing several options, leaving you free to choose the one which seems most suitable.
 
It's possible / probable that Gmail will 'complain' about giving access to an unverified third-party app. If this keeps you from using Claws to access your Gmail, you may need to log in to Gmail's web-mail interface and review / revise your security settings there. This may involve dismissing the warning Google gives about the Project that you set up for Claws to access GMail on your account. If you dismiss a Warning, Google may then ask you why you are dismissing it, providing several options, leaving you free to choose the one which seems most suitable.
 
  
 
=== Setting up OAuth 2.0 for Microsoft - for Outlook or Exchange ===
 
=== Setting up OAuth 2.0 for Microsoft - for Outlook or Exchange ===
  
Sign in to microsoft account
+
Sign in to Microsoft account
  
 
Go to Azure Active Directory > App registrations
 
Go to Azure Active Directory > App registrations
Line 84: Line 82:
  
 
   Display name: Anything you choose
 
   Display name: Anything you choose
   Application (client) ID - will be auto generated
+
   Supported account types - set to "Accounts in any organizational directory… and personal Microsoft accounts…" (Note: This will be shown on the app’s ‘Authentication’ page.) (It will also be represented on the app's ‘Overview’ page as "All Microsoft account users".)
   Object ID - will be auto generated
+
  Select a platform: "Public client/native..."
  Directory (tenant) ID - will be auto generated
+
   Redirect URI: <nowiki>https://login.microsoftonline.com/common/oauth2/nativeclient</nowiki>
  Supported account types - set to "All Microsoft account users"
+
 
 +
Once you've adjusted settings as desired, click on the 'Register' button.
 +
 
 +
(Note: Creating a new registration will result in the auto-generation of an application (client) ID, an object ID, and a directory (tenant) ID, all of which will then be visible on the app’s ‘Overview’ page.)
  
 
Once app is registered you can configure it:
 
Once app is registered you can configure it:
  
Branding tab - any entries you like
+
Quickstart page - Leave alone
 +
 
 +
Integration assistant page - Leave alone
  
Authentication tab -
+
Branding page - any entries you like
  Redirect URI: https://login.microsoftonline.com/common/oauth2/nativeclient
 
  Supported account types: "Accounts in any organizational directory (Any
 
  Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)"
 
  
Certificates & secrets tab - No entries needed
+
Authentication page - Confirm that the ‘redirect URI’ you set during registration has its box checked. You can also add/delete redirect URI’s on this page, as necessary.
  
Token configuration - No entries needed
+
Certificates & secrets page - No entries needed
  
API permissions tab - Add these:
+
Token configuration page - No entries needed
 +
 
 +
API permissions page - Add these:
  
 
Microsoft Graph:
 
Microsoft Graph:
Line 112: Line 114:
 
   - SMTP.Send
 
   - SMTP.Send
  
Expose an API tab - No entries needed
+
Expose an API page - No entries needed
 
 
Owners tab - No entries needed
 
  
Manifest tab - Leave at defaults
+
Owners page - No entries needed
  
Quickstart tab - Leave alone
+
Manifest page - Leave at defaults
  
Integration assistant - Leave alone
+
Once the app is configured, the Client ID (also called Application ID) can be copied over to Claws Mail's corresponding Client ID field. (The Client ID is shown on the app's 'Overview' page in Azure.) No Client Secret is needed - leave that entry blank in Claws Mail's corresponding Client Secret field.
  
Once configured the ClientID (also called Application ID) can be copied over to Claws Mail custom ClientID box. No Client Secret is needed - leave that entry blank in Claws Mail's custom Client Secret box.
+
Note: If you are using an email account managed by a third-party organization using Microsoft’s email systems, then when you attempt to get an authorization code you may see a screen that says something like ‘Approval Required’  //  ‘This app requires your admin’s approval...’. This is likely because Claws Mail is not ‘published’ by a ‘verified publisher’ or because for some other reason the organization has decided to limit the apps to which users can give permissions. There may be a field where you can enter justification for requesting this app, after which you can click on ‘Request approval’. Then you may see a notice that says the request has been sent to your ‘admin’ and that you’ll receive an email in regards to whether it’s been approved or not. You may want to reach out to your email administrator to see if they got the request, to let them know it is a legitimate request from you, and perhaps provide a link to the Claws Mail website and/or other information about the ‘app’ for which you are wanting them to give you consent permissions. (The above details may be different depending on how the organization has configured their 'user consent' settings.) Ultimately it will be up to the organization (rather than Microsoft or yourself) as to whether you will be able to give Claws the access it needs.

Revision as of 15:36, 4 May 2022


Claws Mail Account Settings for OAuth 2.0

When setting up an account with OAuth2, besides correctly filling out the 'OAuth2' page, you also need to make sure you have the correct settings on the 'Receive' and 'Send' pages:

  'Receive' page (POP): Authenticate before POP connection: Authentication method = 'OAuth2'.

  'Receive' page (IMAP): Authentication method = 'OAuth2'.

  'Send' page (POP / IMAP): SMTP Authentication: Authentication method = 'OAuth2'.


Setting up OAuth 2.0 for Gmail

Follow the instructions here: https://support.google.com/googleapi/answer/6158849

Note: If you use more than one Google/Gmail account, make sure you are signed in to Google Cloud Platform with the desired account before creating a project or changing any settings. (It is possible to be signed into multiple accounts; just make sure the browser tab/window you are working in is controlled by the correct account.)

When setting up the project use these settings:

  Project name: Anything of your choice

  Publishing status (of project): 'In Production'

  User type: External

Notes related to the above:

1. If/when you create a new project, if it appears that the process has stalled, look in the top-right corner for a notification icon that you can click on and then select the relevant project. This should then open that project's dashboard so you can continue with the process. (As of 24 Mar 2022.)

2. Regarding Google's above-linked instructions related to the "Credentials" page: Where it says "Click 'New Credentials'" it should read "Click '+ CREATE CREDENTIALS'" (as of 24 Mar 2022).

3. Regarding "Publishing status", the initial default is 'Testing'. To change this to 'In Production' click on the 'Publish App' button in the 'Publishing status' section of the 'OAuth Consent Screen', and then click on 'Confirm'. This results in the status changing to ‘In Production’ and a new section ‘Verification Status’ showing with a ‘Needs verification’ status, which can be safely ignored. If this doesn't work for some reason, you can switch back to 'Testing' status on the same 'OAuth Consent Screen' page you used before. For this status to work you need to make sure you've added the desired email address to the 'Test Users' list on the 'Edit App Registration' - 'Test Users' page of the 'OAuth Consent Screen' setup process (or on the main 'OAuth Consent Screen' page). Note that with this status each authorization code will only last for seven days, after which you will be unable to connect and will see authorization errors in the network log. To get a new authorization code, go to the 'OAuth2' page of the Claws Mail settings and repeat the steps for getting an authorization code and completing authorization. (Note that there is no need to get a new client ID or client secret.) (as of 17 Apr 2022)


OAuth consent screen settings:

  App name: Anything of your choice

  User support email: Your own email

  Developer email: Your own email

  App domain entries: Leave blank

Scopes settings:

  Click on 'Add or Remove Scopes'.

  Select (check the box) this entry: "Gmail API, https://mail.google.com/, Read, compose, send and
      permanently delete all your email from Gmail"

      (Note that the list is in alphabetical order and you may need to go to a later page to find this entry.
       Also, if you can't find it in the list, you can enter the URL manually at the bottom of the page to add it to the list.)

  Click on 'Update'.

  Confirm that the section 'Your restricted scopes' shows the entry you just added.

  Click on 'Save and Continue'.

Getting the Client ID

  APIs and Services on the left menu, then Credentials entry

  Copy the Client ID to the corresponding field on Claws Mail's account settings' 'Oauth2' page.

  Select "Edit OAuth Credentials" (pencil icon), then copy the Client Secret to the corresponding field on Claws Mail's account settings' 'Oauth2' page.

Troubleshooting:

It's possible / probable that Gmail will 'complain' about giving access to an unverified third-party app. If this keeps you from using Claws to access your Gmail, you may need to log in to Gmail's web-mail interface and review / revise your security settings there. This may involve dismissing the warning Google gives about the Project that you set up for Claws to access GMail on your account. If you dismiss a Warning, Google may then ask you why you are dismissing it, providing several options, leaving you free to choose the one which seems most suitable.

Setting up OAuth 2.0 for Microsoft - for Outlook or Exchange

Sign in to Microsoft account

Go to Azure Active Directory > App registrations

Direct link: https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

Choose "New Registration"

 Display name: Anything you choose
 Supported account types - set to "Accounts in any organizational directory… and personal Microsoft accounts…" (Note: This will be shown on the app’s ‘Authentication’ page.) (It will also be represented on the app's ‘Overview’ page as "All Microsoft account users".)
 Select a platform: "Public client/native..."
 Redirect URI: https://login.microsoftonline.com/common/oauth2/nativeclient

Once you've adjusted settings as desired, click on the 'Register' button.

(Note: Creating a new registration will result in the auto-generation of an application (client) ID, an object ID, and a directory (tenant) ID, all of which will then be visible on the app’s ‘Overview’ page.)

Once app is registered you can configure it:

Quickstart page - Leave alone

Integration assistant page - Leave alone

Branding page - any entries you like

Authentication page - Confirm that the ‘redirect URI’ you set during registration has its box checked. You can also add/delete redirect URI’s on this page, as necessary.

Certificates & secrets page - No entries needed

Token configuration page - No entries needed

API permissions page - Add these:

Microsoft Graph:

 - IMAP.AccessAsUser.All
 - Mail.ReadWrite
 - Mail.Send
 - offline_access
 - POP.AccessAsUser.All
 - SMTP.Send

Expose an API page - No entries needed

Owners page - No entries needed

Manifest page - Leave at defaults

Once the app is configured, the Client ID (also called Application ID) can be copied over to Claws Mail's corresponding Client ID field. (The Client ID is shown on the app's 'Overview' page in Azure.) No Client Secret is needed - leave that entry blank in Claws Mail's corresponding Client Secret field.

Note: If you are using an email account managed by a third-party organization using Microsoft’s email systems, then when you attempt to get an authorization code you may see a screen that says something like ‘Approval Required’ // ‘This app requires your admin’s approval...’. This is likely because Claws Mail is not ‘published’ by a ‘verified publisher’ or because for some other reason the organization has decided to limit the apps to which users can give permissions. There may be a field where you can enter justification for requesting this app, after which you can click on ‘Request approval’. Then you may see a notice that says the request has been sent to your ‘admin’ and that you’ll receive an email in regards to whether it’s been approved or not. You may want to reach out to your email administrator to see if they got the request, to let them know it is a legitimate request from you, and perhaps provide a link to the Claws Mail website and/or other information about the ‘app’ for which you are wanting them to give you consent permissions. (The above details may be different depending on how the organization has configured their 'user consent' settings.) Ultimately it will be up to the organization (rather than Microsoft or yourself) as to whether you will be able to give Claws the access it needs.