Merge lp:~gary-wzl77/account-plugins/onedrive_provider into lp:account-plugins

Proposed by Gary.Wang
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 179
Merged at revision: 179
Proposed branch: lp:~gary-wzl77/account-plugins/onedrive_provider
Merge into: lp:account-plugins
Diff against target: 255 lines (+79/-41)
10 files modified
Makefile.am (+3/-2)
configure.ac (+9/-9)
data/providers/microsoft.provider.in.in (+26/-0)
data/providers/windows-live.provider.in.in (+0/-26)
debian/account-plugin-microsoft.install (+3/-0)
debian/control (+8/-1)
debian/rules (+2/-2)
qml/Makefile.am (+1/-0)
qml/microsoft/Main.qml (+27/-0)
src/config.vapi (+0/-1)
To merge this branch: bzr merge lp:~gary-wzl77/account-plugins/onedrive_provider
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Needs Fixing
Review via email: mp+308236@code.launchpad.net

Commit message

Add onedrive account plugin.

Description of the change

Add onedrive account plugin.

Please find the onedrive scope at the following link for a quick review.
https://drive.google.com/open?id=0B2H9ECPSSfqIeVhUTHo5dXZRcHM

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Gary! I think that the plugin should be called Windows Live, because OneDrive it's only one of its services.

We already had a Windows Live plugin, it got removed here:
http://bazaar.launchpad.net/~online-accounts/account-plugins/trunk/revision/150

but the file in data/providers/facebook.provider.in.in is still there, so you can update it instead.
You should also update the debian/control file to remove the line "Conflicts: account-plugin-windows-live," which is no longer relevant now.

review: Needs Fixing
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Hi mandy
    Please check the following link
    https://msdn.microsoft.com/en-us/library/office/dn631819.aspx

    "Instead of using the Live SDK, you might want to try out the new OneDrive API. The OneDrive API is a RESTful API, that works directly with OneDrive, on many platforms, and *completely independent* of the Live SDK. This API provides a faster way to authenticate users, allows large file uploads, and more."

    Also you can find the onedrive oauth dev page here.
    https://dev.onedrive.com/auth/msa_oauth.htm

    On the other hand, in order to easily to find "correct" account plugin from scopes/apps, I tend to use 'onedrive' as account plugin name, instead of "window live".
    As we have onedrive scope and storage provider here already.
    https://code.launchpad.net/storage-provider-onedrive
    https://code.launchpad.net/~hanloon-team/hanloon/onedrive_scope

    I'd like to hear you options on this.
    Thanks.

Revision history for this message
Alberto Mardegan (mardy) wrote :

> Hi mandy
> Please check the following link
> https://msdn.microsoft.com/en-us/library/office/dn631819.aspx
>
> "Instead of using the Live SDK, you might want to try out the new OneDrive
> API. The OneDrive API is a RESTful API, that works directly with OneDrive, on
> many platforms, and *completely independent* of the Live SDK. This API
> provides a faster way to authenticate users, allows large file uploads, and
> more."

Yes, that's about the recommended API to use, but:

> Also you can find the onedrive oauth dev page here.
> https://dev.onedrive.com/auth/msa_oauth.htm

OneDrive is still using the Live account for authentication. Apart from a change in the scopes list, all other authentication parameters are the same. Given that in the future we might support other services provided by the Live account, it's not a good idea to refer to this provider as "onedrive".

> On the other hand, in order to easily to find "correct" account plugin
> from scopes/apps, I tend to use 'onedrive' as account plugin name, instead of
> "window live".
> As we have onedrive scope and storage provider here already.
> https://code.launchpad.net/storage-provider-onedrive
> https://code.launchpad.net/~hanloon-team/hanloon/onedrive_scope

Given that at the moment OneDrive is the only service we support for the Live account, I don't have any strong objections if you want to set the display name of the Live account to "OneDrive", so that users will find it more easily. However, the provider id should be not specific to OneDrive, but instead refer to Microsoft in general.

I now see that the Windows Live brand is actually discontinued [1], so even though the website is called live.com, it seems that Microsoft is trying to forget that name and instead call it just "Microsoft account", as in [2] and [3].
So, my suggestion is to use "microsoft" as provider ID.

[1] https://en.wikipedia.org/wiki/Windows_Live
[2] https://www.microsoft.com/en-us/account/
[3] https://login.live.com/login.srf

177. By Gary.Wang

1.use microsoft as added account plugin name.
2.remove the deprecated account(windows-live).

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

As provider id is changed to "microsoft", the click package needs some adjustment accordingly.
Please find the latest onedrive scope here.
https://drive.google.com/open?id=0B2H9ECPSSfqIOU5iUHYxaWVPM2M

Thanks.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Thanks Gary! Please have a look at the comments inline, there are a few changes I'd recommend doing, but otherwise it's good!

review: Needs Fixing
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Sorry for the late reply. Please see the inline comment.
Thanks.

178. By Gary.Wang

1.fixed translations field("Microsoft" -> "account-plugins")
2.fixed redirect URL with recommended one.

179. By Gary.Wang

query user information so that we can display it on account page.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Looks good, thanks!

review: Approve
180. By Gary.Wang

minor code change as windows-live.provider is deprecated.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Gary, after trying out this branch I would like to request some changes. You can see that I've proposed a branch, please merge it into this one.

The most serious problem I've found is that I had a live.com account I had been using for testing, but I never used onedrive before with that account. When I tried to create the account in my phone the authentication went fine, I could get the access code, but then getting the username was failing:

=================
ui-proxy.cpp 184 onDataReady QMap(("code", QVariant(QString, "finished") ) ( "data" , QVariant(QVariantMap, QMap(("UrlResponse", QVariant(QString, "https://login.live.com/oauth20_desktop.srf?lc=1040#access_token=XXX&token_type=bearer&expires_in=3600&scope=onedrive.readwrite onedrive.appfolder onedrive.readonly&user_id=AAAAAAAAAAAAAAAAAAAAAPywB7MPl1COV-NhKCYqWDw") ) ) ) ) ( "delay" , QVariant(int, 0) ) ( "id" , QVariant(int, 1) ) ( "interface" , QVariant(QString, "com.nokia.singlesignonui") ) )
browser-request.cpp 125 ~BrowserRequestPrivate
browser-request.cpp 325 closeView
qml: error: 403
qml: response text: {"error":{"code":"accessDenied","message":"Access Denied"}}
qml: Removing credentials...
qml: ====== PLUGIN FINISHED ======
provider-request.cpp 175 deny
=================

I tried many times, and it always failed. Then I tried to go to the onedrive site from the browser, and after logging in (with the same account) I was asked to accept the terms & conditions, and then I got to the main web page of onedrive where I can see my folders (all empty, since I never used it).
After doing this step, I tried creating the account on the phone again, and this time it worked.

To me, it sounds like a bug in the onedrive server, but I wonder if we should handle it better; maybe you can change the code in the onedrive QML plugin, and if the username cannot be obtained you can just do 'callback("")' (that is, you return an empty username) instead of calling cancel(). What do you think?

Also, I don't think we should include the user ID in the display name, it makes the display name too long (in my phone, it occupies 2 rows!). Maybe we should use the user ID only if the user name is empty. Can you please change this?

review: Needs Fixing
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Yes, I hit the same problem if user's not accepted the terms & conditions yet.

1...Return an empty username instead of calling cancel
Basically, I think empty username is sth we need to avoid since we have been discussing this issue with michi and james that users can't distinguish two Microsoft account when they have two microsoft account logged in if they hit the above problem. Yes, I know it's a rare case.
2. Maybe we should use the user ID only if the user name is empty. Can you please change this?
The reason why I append user id here is that Microsoft didn't provider user email address in response body so that there is probably a rare case that two same accounts (e.g. two "Gary" in display name field) are shown in account page, which makes users confused.

However, I saw your merge proposal, You call cancel() if user name is not be obtained and still append user id into display name, which look good.

181. By Gary.Wang

Merge mardy's branch to use microsoft graph API.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2016-08-31 06:50:13 +0000
+++ Makefile.am 2016-11-08 08:02:34 +0000
@@ -90,12 +90,12 @@
90 data/providers/linkedin.provider.in.in \90 data/providers/linkedin.provider.in.in \
91 data/providers/instagram.provider.in.in \91 data/providers/instagram.provider.in.in \
92 data/providers/mcloud.provider.in.in \92 data/providers/mcloud.provider.in.in \
93 data/providers/microsoft.provider.in.in \
93 data/providers/owncloud.provider.in.in \94 data/providers/owncloud.provider.in.in \
94 data/providers/sina.provider.in.in \95 data/providers/sina.provider.in.in \
95 data/providers/sohu.provider.in.in \96 data/providers/sohu.provider.in.in \
96 data/providers/twitter.provider.in.in \97 data/providers/twitter.provider.in.in \
97 data/providers/vk.provider.in.in \98 data/providers/vk.provider.in.in
98 data/providers/windows-live.provider.in.in
9999
100providers_DATA = \100providers_DATA = \
101 $(providers_in_in_files:.provider.in.in=.provider)101 $(providers_in_in_files:.provider.in.in=.provider)
@@ -141,6 +141,7 @@
141iconsdir = $(datadir)/icons/hicolor/32x32/apps141iconsdir = $(datadir)/icons/hicolor/32x32/apps
142dist_icons_DATA = \142dist_icons_DATA = \
143 data/icons/mcloud.png \143 data/icons/mcloud.png \
144 data/icons/microsoft.png \
144 data/icons/owncloud.png \145 data/icons/owncloud.png \
145 data/icons/vk.png146 data/icons/vk.png
146147
147148
=== modified file 'configure.ac'
--- configure.ac 2016-06-16 11:48:50 +0000
+++ configure.ac 2016-11-08 08:02:34 +0000
@@ -242,6 +242,14 @@
242AC_SUBST(MCLOUD_CLIENT_ID, ["$mcloud_client_id"])242AC_SUBST(MCLOUD_CLIENT_ID, ["$mcloud_client_id"])
243AC_SUBST(MCLOUD_CLIENT_SECRET, ["$mcloud_client_secret"])243AC_SUBST(MCLOUD_CLIENT_SECRET, ["$mcloud_client_secret"])
244244
245# Set microsoft client id
246AC_ARG_WITH(microsoft-client-id,
247 [AS_HELP_STRING([--with-microsoft-client-id],
248 [Microsoft client id])],
249 [microsoft_client_id=$withval],
250 [microsoft_client_id="478797ed-02c1-442b-bebd-709401131e7d"])
251AC_SUBST(MICROSOFT_CLIENT_ID, ["$microsoft_client_id"])
252
245# Set VK client id253# Set VK client id
246AC_ARG_WITH(vk-client-id,254AC_ARG_WITH(vk-client-id,
247 [AS_HELP_STRING([--with-vk-client-id],255 [AS_HELP_STRING([--with-vk-client-id],
@@ -250,14 +258,6 @@
250 [vk_client_id="5404010"])258 [vk_client_id="5404010"])
251AC_SUBST(VK_CLIENT_ID, ["$vk_client_id"])259AC_SUBST(VK_CLIENT_ID, ["$vk_client_id"])
252260
253# Set Windows Live client id
254AC_ARG_WITH(windows-live-client-id,
255 [AS_HELP_STRING([--with-windows-live-client-id],
256 [Windows Live client ID])],
257 [windows_live_client_id=$withval],
258 [windows_live_client_id="00000000480CBF28"])
259AC_SUBST(WINDOWS_LIVE_CLIENT_ID, ["$windows_live_client_id"])
260
261AC_CONFIG_FILES([261AC_CONFIG_FILES([
262 data/providers/facebook.provider.in262 data/providers/facebook.provider.in
263 data/providers/flickr.provider.in263 data/providers/flickr.provider.in
@@ -267,12 +267,12 @@
267 data/providers/linkedin.provider.in267 data/providers/linkedin.provider.in
268 data/providers/instagram.provider.in268 data/providers/instagram.provider.in
269 data/providers/mcloud.provider.in269 data/providers/mcloud.provider.in
270 data/providers/microsoft.provider.in
270 data/providers/owncloud.provider.in271 data/providers/owncloud.provider.in
271 data/providers/sina.provider.in272 data/providers/sina.provider.in
272 data/providers/sohu.provider.in273 data/providers/sohu.provider.in
273 data/providers/twitter.provider.in274 data/providers/twitter.provider.in
274 data/providers/vk.provider.in275 data/providers/vk.provider.in
275 data/providers/windows-live.provider.in
276 Makefile276 Makefile
277 po/Makefile.in277 po/Makefile.in
278 qml/Makefile278 qml/Makefile
279279
=== added file 'data/icons/microsoft.png'
280Binary files data/icons/microsoft.png 1970-01-01 00:00:00 +0000 and data/icons/microsoft.png 2016-11-08 08:02:34 +0000 differ280Binary files data/icons/microsoft.png 1970-01-01 00:00:00 +0000 and data/icons/microsoft.png 2016-11-08 08:02:34 +0000 differ
=== added file 'data/providers/microsoft.provider.in.in'
--- data/providers/microsoft.provider.in.in 1970-01-01 00:00:00 +0000
+++ data/providers/microsoft.provider.in.in 2016-11-08 08:02:34 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="microsoft">
3 <name>Microsoft</name>
4 <icon>microsoft</icon>
5 <translations>account-plugins</translations>
6 <domains>.*live\.com</domains>
7 <plugin>generic-oauth</plugin>
8 <single-account>true</single-account>
9 <template>
10 <group name="auth">
11 <setting name="method">oauth2</setting>
12 <setting name="mechanism">user_agent</setting>
13 <group name="oauth2">
14 <group name="user_agent">
15 <setting name="Host">login.live.com</setting>
16 <setting name="AuthPath">oauth20_authorize.srf</setting>
17 <setting name="RedirectUri">https://login.live.com/oauth20_desktop.srf</setting>
18 <setting name="ResponseType">token</setting>
19 <setting name="ClientId">@MICROSOFT_CLIENT_ID@</setting>
20 <setting type="as" name="Scope">['User.Read', 'Files.ReadWrite']</setting>
21 <setting type="b" name="DisableStateParameter">true</setting>
22 </group>
23 </group>
24 </group>
25 </template>
26</provider>
027
=== removed file 'data/providers/windows-live.provider.in.in'
--- data/providers/windows-live.provider.in.in 2013-11-14 11:42:15 +0000
+++ data/providers/windows-live.provider.in.in 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2<provider id="windows-live">
3 <name>Windows Live</name>
4 <icon>live</icon>
5 <translations>account-plugins</translations>
6 <domains>.*live\.com</domains>
7 <plugin>generic-oauth</plugin>
8
9 <template>
10 <group name="auth">
11 <setting name="method">oauth2</setting>
12 <setting name="mechanism">web_server</setting>
13 <group name="oauth2">
14 <group name="web_server">
15 <setting name="Host">login.live.com</setting>
16 <setting name="AuthPath">/oauth20_authorize.srf</setting>
17 <setting name="TokenPath">/oauth20_token.srf</setting>
18 <setting name="RedirectUri">https://login.live.com/oauth20_desktop.srf</setting>
19 <setting name="ResponseType">code</setting>
20 <setting name="Scope" type="as">['wl.messenger','wl.offline_access','wl.emails', 'wl.imap']</setting>
21 <setting name="ClientId">@WINDOWS_LIVE_CLIENT_ID@</setting>
22 </group>
23 </group>
24 </group>
25 </template>
26</provider>
270
=== added file 'debian/account-plugin-microsoft.install'
--- debian/account-plugin-microsoft.install 1970-01-01 00:00:00 +0000
+++ debian/account-plugin-microsoft.install 2016-11-08 08:02:34 +0000
@@ -0,0 +1,3 @@
1usr/share/accounts/providers/microsoft.provider
2usr/share/accounts/qml-plugins/microsoft/*.qml
3usr/share/icons/hicolor/32x32/apps/microsoft.png
04
=== modified file 'debian/control'
--- debian/control 2016-08-31 06:50:13 +0000
+++ debian/control 2016-11-08 08:02:34 +0000
@@ -26,7 +26,6 @@
26Architecture: any26Architecture: any
27Depends: ${shlibs:Depends}, ${misc:Depends},27Depends: ${shlibs:Depends}, ${misc:Depends},
28 signon-plugin-oauth2,28 signon-plugin-oauth2,
29Conflicts: account-plugin-windows-live,
30Description: Online account plugin support lib for Unity 7 - generic OAuth29Description: Online account plugin support lib for Unity 7 - generic OAuth
31 Support library for the Unity 7 OAuth-based online account plugins30 Support library for the Unity 7 OAuth-based online account plugins
3231
@@ -156,6 +155,14 @@
156 This plugin adds support for creating mCloud accounts in the Unity Control155 This plugin adds support for creating mCloud accounts in the Unity Control
157 Center156 Center
158157
158Package: account-plugin-microsoft
159Architecture: all
160Depends: ${misc:Depends},
161 ubuntu-system-settings-online-accounts,
162Description: Online account plugin for Unity - Microsoft
163 This plugin adds support for creating microsoft accounts in the Unity Control
164 Center
165
159Package: account-plugin-owncloud166Package: account-plugin-owncloud
160Architecture: all167Architecture: all
161Depends: ${misc:Depends},168Depends: ${misc:Depends},
162169
=== modified file 'debian/rules'
--- debian/rules 2016-05-31 08:53:33 +0000
+++ debian/rules 2016-11-08 08:02:34 +0000
@@ -11,7 +11,6 @@
11 dh_auto_configure -- --enable-qml-plugins \11 dh_auto_configure -- --enable-qml-plugins \
12 --with-twitter-consumer-key="NGOB5S7sICsj6epjh0PhAw" \12 --with-twitter-consumer-key="NGOB5S7sICsj6epjh0PhAw" \
13 --with-twitter-consumer-secret="rbUEJCBEokMnGZd8bubd0QL2cSmoCjJeyiSJpnx3OM0" \13 --with-twitter-consumer-secret="rbUEJCBEokMnGZd8bubd0QL2cSmoCjJeyiSJpnx3OM0" \
14 --with-windows-live-client-id="00000000400D5635" \
15 --with-facebook-client-id="271112146382618" \14 --with-facebook-client-id="271112146382618" \
16 --with-foursquare-client-id="1I2UNJXPHNDZT3OPZOOA5LCPIUEUJFMKRXSF42UFCN1KXKTK" \15 --with-foursquare-client-id="1I2UNJXPHNDZT3OPZOOA5LCPIUEUJFMKRXSF42UFCN1KXKTK" \
17 --with-google-client-id="759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com" \16 --with-google-client-id="759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com" \
@@ -24,12 +23,13 @@
24 --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" \23 --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" \
25 --with-mcloud-client-id="APP1ZtqoN3R0002" \24 --with-mcloud-client-id="APP1ZtqoN3R0002" \
26 --with-mcloud-client-secret="A70EFCDC91456349E7FDECF0A33574AC" \25 --with-mcloud-client-secret="A70EFCDC91456349E7FDECF0A33574AC" \
26 --with-microsoft-client-id="478797ed-02c1-442b-bebd-709401131e7d" \
27 --with-vk-client-id="5402699"27 --with-vk-client-id="5402699"
2828
29override_dh_install:29override_dh_install:
30 rm -f debian/*/usr/lib/*/*/*.la30 rm -f debian/*/usr/lib/*/*/*.la
31 # the service is not valid anymore so we don't ship those31 # the service is not valid anymore so we don't ship those
32 rm debian/tmp/etc/signon-ui/webkit-options.d/login.live.com.conf debian/tmp/usr/share/accounts/providers/windows-live.provider32 rm debian/tmp/etc/signon-ui/webkit-options.d/login.live.com.conf
33 mkdir -p debian/tmp/usr/share/account-plugins/tools33 mkdir -p debian/tmp/usr/share/account-plugins/tools
34 dh_install --fail-missing34 dh_install --fail-missing
3535
3636
=== modified file 'qml/Makefile.am'
--- qml/Makefile.am 2016-06-01 13:01:07 +0000
+++ qml/Makefile.am 2016-11-08 08:02:34 +0000
@@ -3,6 +3,7 @@
3 flickr/Main.qml \3 flickr/Main.qml \
4 google/Main.qml \4 google/Main.qml \
5 mcloud/Main.qml \5 mcloud/Main.qml \
6 microsoft/Main.qml \
6 owncloud/Main.qml \7 owncloud/Main.qml \
7 owncloud/NewAccount.qml \8 owncloud/NewAccount.qml \
8 twitter/Main.qml \9 twitter/Main.qml \
910
=== added directory 'qml/microsoft'
=== added file 'qml/microsoft/Main.qml'
--- qml/microsoft/Main.qml 1970-01-01 00:00:00 +0000
+++ qml/microsoft/Main.qml 2016-11-08 08:02:34 +0000
@@ -0,0 +1,27 @@
1import Ubuntu.OnlineAccounts.Plugin 1.0
2
3OAuthMain {
4 creationComponent: OAuth {
5 function getUserName(reply, callback) {
6 var http = new XMLHttpRequest();
7 var url = "https://graph.microsoft.com/v1.0/me";
8 http.open("GET", url, true);
9 http.setRequestHeader("Authorization", "bearer " + reply.AccessToken);
10 http.onreadystatechange = function() {
11 if (http.readyState === 4) {
12 if (http.status === 200) {
13 console.log("response text: " + http.responseText);
14 var response = JSON.parse(http.responseText);
15 callback(response.userPrincipalName ? response.userPrincipalName : response.displayName);
16 } else {
17 console.log("error: " + http.status);
18 console.log("response text: " + http.responseText);
19 cancel();
20 }
21 }
22 };
23 http.send(null);
24 return true;
25 }
26 }
27}
028
=== modified file 'src/config.vapi'
--- src/config.vapi 2013-04-09 08:45:38 +0000
+++ src/config.vapi 2016-11-08 08:02:34 +0000
@@ -36,5 +36,4 @@
36 public const string SINA_CONSUMER_SECRET;36 public const string SINA_CONSUMER_SECRET;
37 public const string SOHU_CLIENT_ID;37 public const string SOHU_CLIENT_ID;
38 public const string SOHU_CLIENT_SECRET;38 public const string SOHU_CLIENT_SECRET;
39 public const string WINDOWS_LIVE_CLIENT_ID;
40}39}

Subscribers

People subscribed via source and target branches