You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixgoogleapis#187. Fixed default redirect uri used by this package.
Fixed Account.is_authenticated property was returning True/None instead of True/False.
Updated Readme to change the app registration portal to azure, and to show the usage of the new default redirect uri.
Bumped version
Copy file name to clipboardExpand all lines: README.md
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,22 +117,25 @@ The `Connection` Class handles the authentication.
117
117
This section is explained using Microsoft Graph Protocol, almost the same applies to the Office 365 REST API.
118
118
119
119
##### Authentication Flow
120
-
1. To work with oauth you first need to register your application at [Microsoft Application Registration Portal](https://apps.dev.microsoft.com/).
121
-
122
-
1. Login at [Microsoft Application Registration Portal](https://apps.dev.microsoft.com/)
123
-
2. Create an app, note your app id (client_id)
124
-
3. Generate a new password (client_secret) under "Application Secrets" section
125
-
4. Under the "Platform" section, add a new Web platform and set "https://outlook.office365.com/owa/" as the redirect URL
126
-
5. Under "Microsoft Graph Permissions" section, add the delegated permissions you want (see scopes), as an example, to read and send emails use:
120
+
1. To work with oauth you first need to register your application at [Azure App Registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade).
121
+
122
+
1. Login at [Azure Portal (App Registrations)](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)
123
+
1. Create an app. Set a name.
124
+
1. In Supported account types choose "Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)", if you are using a personal account.
125
+
1. Set the redirect uri (Web) to: `https://login.microsoftonline.com/common/oauth2/nativeclient` and click register. This is the default redirect uri used by this library, but you can use any other if you want.
126
+
1. Write down the Application (client) ID. You will need this value.
127
+
1. Under "Certificates & secrets", generate a new client secret. Set the expiration preferably to never.
128
+
1. Write down the value of the client secret created now. It will be hidden later on.
129
+
1. Under Api Permissions add the delegated permissions for Microsoft Graph you want (see scopes), as an example, to read and send emails use:
127
130
1. Mail.ReadWrite
128
-
2. Mail.Send
129
-
3. User.Read
130
-
4. It is highly recommended to add "offline_access" permission. If not you will have to re-authenticate every hour.
131
+
1. Mail.Send
132
+
1. User.Read
133
+
1. It is highly recommended to add "offline_access" permission. If not you will have to re-authenticate every hour.
131
134
132
-
2. Then you need to login for the first time to get the access token by consenting the application to access the resources it needs.
135
+
1. Then you need to login for the first time to get the access token by consenting the application to access the resources it needs.
133
136
1. To authenticate (login) call `account.authenticate` and pass the scopes you want (the ones you previously added on the app registration portal).
134
137
135
-
You can pass "protocol scopes" (like: "https://graph.microsoft.com/Calendars.ReadWrite") to the method or use "[scope helpers](https://github.com/O365/python-o365/blob/master/O365/connection.py#L33)" like ("message_all").
138
+
You can pass "protocol scopes" (like: "https://graph.microsoft.com/Calendars.ReadWrite") to the method or use "[scope helpers](https://github.com/O365/python-o365/blob/master/O365/connection.py#L34)" like ("message_all").
136
139
If you pass protocol scopes, then the `account` instance must be initialized with the same protocol used by the scopes. By using scope helpers you can abstract the protocol from the scopes and let this library work for you.
137
140
Finally, you can mix and match "protocol scopes" with "scope helpers".
138
141
Go to the [procotol section](#protocols) to know more about them.
@@ -148,14 +151,14 @@ This section is explained using Microsoft Graph Protocol, almost the same applie
148
151
```
149
152
This method call will print a url that the user must visit to give consent to the app on the required permissions.
150
153
151
-
The user must then visit this url and give consent to the application. When consent is given, the page will rediret to: "https://outlook.office365.com/owa/" by default (you can change this).
154
+
The user must then visit this url and give consent to the application. When consent is given, the page will rediret to: "https://login.microsoftonline.com/common/oauth2/nativeclient" by default (you can change this)with a url query param called 'code'.
152
155
153
156
Then the user must copy the resulting page url and paste it back on the console.
154
-
The method will thereturnTrueif the login attempt was succesful.
157
+
The method will thenreturnTrueif the login attempt was succesful.
155
158
156
159
**Take care: the access (and refresh) token must remain protected from unauthorized users.**
157
160
158
-
3. At this point you will have an access token stored that will provide valid credentials when using the api. If you change the scope requested, then the current token won't work, and you will need the user to give consent again on the application to gain access to the new scopes requested.
161
+
1. At this point you will have an access token stored that will provide valid credentials when using the api. If you change the scope requested, then the current token won't work, and you will need the user to give consent again on the application to gain access to the new scopes requested.
159
162
160
163
The access token only lasts **60 minutes**, but the app will automatically request new access tokens through the refresh tokens (ifand only if you added the "offline_access" permission), but note that a refresh token only lasts for90 days. So you must use it before or you will need to request a new access token again (no new consent needed by the user, just a login).
161
164
@@ -628,6 +631,8 @@ for event in birthdays:
628
631
event.decline("No way I'm comming, I'll be in Spain", send_response=False) # decline the event but don't send a reponse to the organizer
629
632
```
630
633
634
+
There are some known issues when working with [shared calendars](https://docs.microsoft.com/en-us/graph/known-issues#calendars) in Microsoft Graph.
635
+
631
636
## OneDrive
632
637
The `Storage`class handles all functionality around One Drive and Document Library Storage in Sharepoint.
0 commit comments