microsoftgraph / msgraph-sdk-android

Microsoft Graph SDK for Android! https://graph.microsoft.io
Other
51 stars 43 forks source link

Photo fetch error for outlook.com accounts #37

Closed morphine9 closed 7 years ago

morphine9 commented 7 years ago

Not sure why photo elements are not returned by photo call

mGraphClient
                    .getMe()
                    .getPhoto()
                    .getContent()
                    .buildRequest()
                    .get(new ICallback<InputStream>() {
                          @Override
                          public void success(final InputStream inputStream) {}

                          @Override
                          public void failure(ClientException ex) {});

scopes added -

"https://graph.microsoft.com/Mail.Send", "https://graph.microsoft.com/User.Read", "https://graph.microsoft.com/User.ReadWrite", "https://graph.microsoft.com/User.ReadBasic.All", "https://graph.microsoft.com/User.Read.All", "https://graph.microsoft.com/User.ReadWrite.All",

E: OneDrive Service exception [This is an unexpected error from Graph, please report this at https://github.com/microsoftgraph/msgraph-sdk-android/issues]
E: GET https://graph.microsoft.com/v1.0/me/photo/$value
E: SdkVersion : graph-android-v1.2.0
E: Authorization : bearer EwBAA8l6BAAU1sPaz/0rP7ovs9bCsPzXhoCjrNEAAfz1FrVnYGUW4nkK0VNau9xU8WgJVC3b94r8KuEGHvI8a4fv+y5f+3sPU5m+RHLAyp+WQMhkzs3SIUGIkwlNuEKgVfIdBxQ5csgfQ9vYvZpAu7DQU9BFzpBMG31AIx4RDMz/XhDZJV70w4z1OPFDkmGdhZbZn4GcyyQHT6rgGY7Ezpc82vsdqerVCe0ZOyW+rgyEDTVU0Ph6aKbMCMZRxkEChbSnF6Z5jWOJMgpgwlSLqzmNGez22OxxhzgYX+bl89XT7n/ecJmKsIlGQ5jDvi5I0o/tFWlQBjCDhdamQAdmCnHB0EbUjxJZIRZd4GFeXPKEDUMdA3HIw5/KsBlmMUgDZgAACKC9smTd+sOfEALKfn18AEzEiA8EYqBeSnyq8wS7QPGL6rjRJAWICyo3zDXBfogZhdHrk9aM6IErX4WfCCSY4BJXYKo2Nj+cURlCHETM5B93fXXM+J3YfmlCb5O+uBJZISpB+EOKISuJRAveforICpsDSjmcRZculJDS2fFWQPsyh3PQ0vY10LP0AU/2pvorUw0ai0n/6c5zu4+EKjTYDAOtmPhyMKb07ucEwVRUUeDOz8IZCmRWj2dHqXkGEd+PUgl5argsE9OcU3LQizcbUJ55Pjc0SATqv5j3MYPj/2rRRgxQm7XJrrgZWas4Y+SoH1kbychoHk7debHJwFPeYLrrG+ClBRaj83JueIC62BoPHP/WzKjwUzzPZcfCx30G4WoJcemcc7TAapYb1LfSwiBIF0XYw24PuTVvFfiEKWQJb5/PnJw/vSQMMhBB3yQSqY8+B7N3wO7pOM0xWsMKSNCEtOc+j0/vdICLO3aGD146wG01gvgA6JyMtTbQ5rhWTBhY88s9gc8gTQgixHR5zyuzp/AtLW1cPPNAPAlYOr85r5+/Uv9tDIWGIcT5RZJwY6GLk/6qTM47kVzzneZbrj/kTc6jTE/h3DxINUMlavSU5cex/vsRYSq/YQr8SrBYo5C5d+MLIL4Q332Hk6wJX2ZhUKy+IUkFMtg2/4IHXz6UDSuOYirSrE6zoMlp8KzcDNY5WcV+9F5syPA6Ag==
E: 501 : Not Implemented
E: Duration : 471.9225
E: Cache-Control : private
E: x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceA","ScaleUnit":"000","Host":"AGSFE_IN_4","ADSiteName":"WST"}}
E: request-id : 62213bcd-2d86-4217-b925-8cd9943bd677
E: X-Powered-By : ASP.NET
E: X-Android-Selected-Protocol : http/1.1
E: X-Android-Response-Source : NETWORK 501
E: client-request-id : 62213bcd-2d86-4217-b925-8cd9943bd677
E: X-Android-Sent-Millis : 1482283545390
E: Content-Type : application/json
E: Date : Wed, 21 Dec 2016 01:25:47 GMT
E: Server : Microsoft-IIS/8.5
E: Transfer-Encoding : chunked
E: X-Android-Received-Millis : 1482283545940
E: {
E:    "error": {
E:       "code": "GetUserPhoto",
E:       "message": "The operation is not supported.",
E:       "innerError": {
E:          "request-id": "62213bcd-2d86-4217-b925-8cd9943bd677",
E:          "date": "2016-12-21T01:25:48"
E:       }
E:    }
E: }
E: Throwable detail: 
   com.microsoft.graph.http.GraphFatalServiceException: [This is an unexpected error from Graph, please report this at https://github.com/microsoftgraph/msgraph-sdk-android/issues]
   GET https://graph.microsoft.com/v1.0/me/photo/$value
   SdkVersion : graph-android-v1.2.0
   Authorization : bearer EwBAA8l6BAAU1sPaz/0rP7ovs9bCsPzXhoCjrNEAAfz1FrVnYGUW4nkK0VNau9xU8WgJVC3b94r8KuEGHvI8a4fv+y5f+3sPU5m+RHLAyp+WQMhkzs3SIUGIkwlNuEKgVfIdBxQ5csgfQ9vYvZpAu7DQU9BFzpBMG31AIx4RDMz/XhDZJV70w4z1OPFDkmGdhZbZn4GcyyQHT6rgGY7Ezpc82vsdqerVCe0ZOyW+rgyEDTVU0Ph6aKbMCMZRxkEChbSnF6Z5jWOJMgpgwlSLqzmNGez22OxxhzgYX+bl89XT7n/ecJmKsIlGQ5jDvi5I0o/tFWlQBjCDhdamQAdmCnHB0EbUjxJZIRZd4GFeXPKEDUMdA3HIw5/KsBlmMUgDZgAACKC9smTd+sOfEALKfn18AEzEiA8EYqBeSnyq8wS7QPGL6rjRJAWICyo3zDXBfogZhdHrk9aM6IErX4WfCCSY4BJXYKo2Nj+cURlCHETM5B93fXXM+J3YfmlCb5O+uBJZISpB+EOKISuJRAveforICpsDSjmcRZculJDS2fFWQPsyh3PQ0vY10LP0AU/2pvorUw0ai0n/6c5zu4+EKjTYDAOtmPhyMKb07ucEwVRUUeDOz8IZCmRWj2dHqXkGEd+PUgl5argsE9OcU3LQizcbUJ55Pjc0SATqv5j3MYPj/2rRRgxQm7XJrrgZWas4Y+SoH1kbychoHk7debHJwFPeYLrrG+ClBRaj83JueIC62BoPHP/WzKjwUzzPZcfCx30G4WoJcemcc7TAapYb1LfSwiBIF0XYw24PuTVvFfiEKWQJb5/PnJw/vSQMMhBB3yQSqY8+B7N3wO7pOM0xWsMKSNCEtOc+j0/vdICLO3aGD146wG01gvgA6JyMtTbQ5rhWTBhY88s9gc8gTQgixHR5zyuzp/AtLW1cPPNAPAlYOr85r5+/Uv9tDIWGIcT5RZJwY6GLk/6qTM47kVzzneZbrj/kTc6jTE/h3DxINUMlavSU5cex/vsRYSq/YQr8SrBYo5C5d+MLIL4Q332Hk6wJX2ZhUKy+IUkFMtg2/4IHXz6UDSuOYirSrE6zoMlp8KzcDNY5WcV+9F5syPA6Ag==

   501 : Not Implemented
   Duration : 471.9225
   Cache-Control : private
   x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceA","ScaleUnit":"000","Host":"AGSFE_IN_4","ADSiteName":"WST"}}
   request-id : 62213bcd-2d86-4217-b925-8cd9943bd677
   X-Powered-By : ASP.NET
   X-Android-Selected-Protocol : http/1.1
   X-Android-Response-Source : NETWORK 501
   client-request-id : 62213bcd-2d86-4217-b925-8cd9943bd677
   X-Android-Sent-Millis : 1482283545390
   Content-Type : application/json
   Date : Wed, 21 Dec 2016 01:25:47 GMT
   Server : Microsoft-IIS/8.5
   Transfer-Encoding : chunked
   X-Android-Received-Millis : 1482283545940
   {
      "error": {
         "code": "GetUserPhoto",
         "message": "The operation is not supported.",
         "innerError": {
            "request-id": "62213bcd-2d86-4217-b925-8cd9943bd677",
            "date": "2016-12-21T01:25:48"
         }
      }
   }

       at com.microsoft.graph.http.DefaultHttpProvider.handleErrorResponse(DefaultHttpProvider.java:345)
       at com.microsoft.graph.http.DefaultHttpProvider.sendRequestInternal(DefaultHttpProvider.java:283)
       at com.microsoft.graph.http.DefaultHttpProvider.access$000(DefaultHttpProvider.java:47)
       at com.microsoft.graph.http.DefaultHttpProvider$1.run(DefaultHttpProvider.java:139)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
morphine9 commented 7 years ago

Seems it works for beta !

kristijanexads commented 7 years ago

any progress on this, I also need profile photo?

Thank you

iambmelt commented 7 years ago

@kristijanexads -- /photo/$value should be live in v1 and should be supported by the client library

kkontus commented 7 years ago

@iambmelt maybe I'm doing something wrong but I'm still receiving following error:

I/System.out: [This is an unexpected error from Graph, please report this at https://github.com/microsoftgraph/msgraph-sdk-android/issues]
I/System.out: GET https://graph.microsoft.com/v1.0/me/photo/$value
I/System.out: SdkVersion : graph-android-v1.2.0
I/System.out: Authorization : bearer EwA4A8l6BAAU7p9QDpi/D7xJLwsTgCg3TskyTaQAAedwQvLhrGUP/R0+3ISAuTOxWZScBBOKGR4MHnWFwx4wwrGbvTgCo7eiJTC0dyR4mRIfka1JeJAaji5+1/yjuA3TdQbyr0UpyBP/6NnuON4LMJyIemMMScfTh/ZO5JE+tX79+pkN2ne5qvD+5q185xRYLvpQqcMRI62yW/2oqYsFOS6eTnrJ9Sct0UHhoz45/G2xoAh5nRtrjgPHtuxNRkWphSHYumAIbVgs+hCxzAMHgb6QnnbGr6rCZIcBe05LIWVkaWx7gpXgu5E9F0SwOBT92UTCuzbNQmu7/PP5PRYz1pMbRgPVUVOX0MYgmxp8dugMsO2N75MVneqIk2fdFDgDZgAACGvL9cvP83D2CAKSba4XRkX89HUwu8BXG5K8lY46UXZFlpq4JHuriQjF3WEhMwNERuSye4BExi7a0nGB/DvYzXhXJtf2NwiiT9n8FE6sb6pG9bHpl+LUl/CqB4uzG787uiV5kfIV4vHO1V+FT4i+mVsFDVb4ns4LVsBgH8smJ0CEyJ9HMjVQL8mKojlK0Y28xLS5WZs+kASuhdcYFEZBMSTwbzYtnLkpu47rTOaWykFv/hC3g29tSDPT58eAUW/FoGyc9gvg7NR1Jo4TGI31Dl+6eTnIo4MMo5pMYmcmT1xXhyoWmEGRknOSUFqH6e+c1eYQm6wEbOmymYeNVttfP7QlNf3LhpOsA1/J6u6173wocWw417zZK5adFzWQb9IKxYVGGWZ8Yc1a2V6gwtZyPV5F5CvSPZX9w5+X1fDm7s4M9pyqV920X7BNr1dXwxPVj9x+oS1MHwQQPezSBRVrUsVAAZ8Yxli01DMvhtsjnN7CMD4lCrMObbIXG0TErBnCiL1pSmf5Yu+rFHgAuvltijbb9f8rNzMjuux3mRAmuTmtLM3QfS9yJWS1USMLpPIc/MNV3X0LA7UGRrMiPYiyi91NO1RwoeZsdZJkabdbMabUSVlRkuiSvLO8qLx3zwg/31zcalJBcfyQD566PQuUgV8e/DzGRVP5avotZ6LGAvsjlTU4i6LCmvE4vXuR2gCeLUo9NwI=
I/System.out: 501 : Not Implemented
I/System.out: Duration : 247.7164
I/System.out: Cache-Control : private
I/System.out: X-Android-Sent-Millis : 1487149922106
I/System.out: Content-Type : application/json
I/System.out: x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"North Europe","Slice":"SliceA","ScaleUnit":"001","Host":"AGSFE_IN_1","ADSiteName":"DUB"}}
I/System.out: request-id : 78bfd90c-3202-46d0-a224-92d7249cfb99
I/System.out: X-Android-Selected-Protocol : http/1.1
I/System.out: Date : Wed, 15 Feb 2017 09:12:00 GMT
I/System.out: Transfer-Encoding : chunked
I/System.out: X-Android-Response-Source : NETWORK 501
I/System.out: client-request-id : 78bfd90c-3202-46d0-a224-92d7249cfb99
I/System.out: X-Android-Received-Millis : 1487149922528
I/System.out: {
I/System.out:    "error": {
I/System.out:       "code": "GetUserPhoto",
I/System.out:       "message": "The operation is not supported.",
I/System.out:       "innerError": {
I/System.out:          "request-id": "78bfd90c-3202-46d0-a224-92d7249cfb99",
I/System.out:          "date": "2017-02-15T09:12:00"
I/System.out:       }
I/System.out:    }
I/System.out: }

I'm using following:

    compile ('com.microsoft.services.msa:msa-auth:0.8.6')
    //compile ('com.microsoft.aad:adal:1.11.0') // not needed for now
    compile('com.microsoft.graph:msgraph-sdk-android:1.2.+')
    compile 'com.microsoft.graph:msa-auth-for-android-adapter:0.9.0'

and making request like this:

mGraphClient.getMe().getPhoto().getContent().buildRequest().get(new ICallback<InputStream>() {
                            @Override
                            public void success(final InputStream inputStream) {
                                System.out.println("success");
                            }

                            @Override
                            public void failure(ClientException ex) {
                                System.out.println("failure");

                                System.out.println(ex.getMessage());
                            }
                        });

also tried with this:

mGraphClient.getMe().getPhoto().buildRequest().get(new ICallback<ProfilePhoto>() {
                @Override
                public void success(ProfilePhoto profilePhoto) {
                    System.out.println(TAG + " success ProfilePhoto profilePhoto");
                    System.out.println(profilePhoto.getRawObject());
                }

                @Override
                public void failure(ClientException ex) {
                    System.out.println(TAG + " failure ProfilePhoto profilePhoto");
                }
            });
        }
iambmelt commented 7 years ago

@kkontus The 501 you are seeing is likely because the currently logged-in User is using an MSA (Microsoft Account) and not a work or school account. Per the Get User Photo documentation, this functionality is currently restricted to work or school accounts only.

kkontus commented 7 years ago

@iambmelt you are right, I missed that note in the docs. Are there any plans to make this available later on through MSA account? I'm currently using LiveSDK for this and upload to OneDrive in my Android app. I was thinking of upgrading the app and use msgraph-sdk-android since one-drive-android SDK doesn't support showing logged user profile photo, but now I see that this is not possible with the msgraph either.

Is there any other option available to get logged user account profile photo?

Thank you

iambmelt commented 7 years ago

@kkontus At a glance, it appears you may be able to get access to this picture data through the Outlook Contacts REST API -- the documentation says that it applies to the following services, although I haven't tested these APIs personally:

Are there any plans to make this available later on through MSA account?

Over time, the MSGraph should gain these features; it's purpose is to act as the single-source of all your Microsoft data stored in the cloud - we're adding new services and functionalities all of the time, and for the most up-to-date public information regarding what's recently been released you can consult our changelog.

kkontus commented 7 years ago

@iambmelt thank you once again for your effort on all my questions.

dfloresgonz commented 6 years ago

@iambmelt was the user photo added after almost a year later?

iambmelt commented 6 years ago

Hi @dfloresgonz - Sadly, no -- per the documentation, 'User > Get Photo' is only supported for work or school mailboxes at this time.

saeed-vayghan commented 5 years ago

My problem solved when I switched to the Beta version. https://graph.microsoft.com/beta/me/photo/$value