OOauth2 Script

Download the script.

The script ooauth2.py is a python script that can be used to obtain the initial refresh token and access token for an app, or to renew an access token, and in both cases obtain the encoded base64 string that is used to add to an authenticate command in an IMAP or SMTP server.

The script assumes that you already registered your app with Microsoft, and that you were given a client-id. For purposes of giving examples, our app will be Alpine. You will see that the name of the app will appear in some of the images below, but we will never give the name of the app in the command line, since it is not necessary.

Microsoft only requires a client-secret for web apps. This script does not use the client-secret, so it cannot be used for web apps. For purposes of this demonstration we assume the client-id is f21dac2f-9145-665a-a876-fde739fe41fb, so we use the option --client_id=f21dac2f-9145-665a-a876-fde739fe41fb in the examples below.

Microsoft asks you to chose the tenant for your app. Your app might be an app for an organization, school, work, a mixture of these, or for everyone. We assume here that we want to use an app that can be used by everyone in the world. This is the default option for the script, but if you want to use a special tenant, you would specify it by adding the --tenant option. For example --tenant=organization. In none of the examples below we use the --tenant option, and this is equivalent to using --tenant=common.

Please send me any and all feedback about this script to eduardo.chappa@gmx.com. New versions of this script can be found in the scripts directory of the Alpine repository at https://repo.or.cz/alpine.git/tree/HEAD:/scripts

Page created on Sun Jun 14 01:55:49 MDT 2020.