Hi Guys i'm new in ionic with sharepoint
I have developed a Mobile app using ionic3 with sharepoint.
Now i have to get user profile picture in my app.
I have tried these are the way can't achieve here is my tried code.
First way tried like this
abc.sharepoint.com/sites/qa/_layouts/15/userphoto.aspx?size="s"&accountname="[email protected]"
Second way tried like this
These url iam geting using people picker result. PictureURL property
https://abc.sharepoint.com/User Photos/ProfilePictures/abc_onmicrosoft_com_MThumb.jpg", "Muthu.jpeg"
These Second method always return
401 UNAUTHORIZED
Above url using to call this method.
- public downloadFile(url: string, fileName: string) {
- let options = this._apiHeaderForImageURL();
- this._http.get(url, options)
- .subscribe((data) => {
- //here converting a blob to base 64 For internal view purpose in image src
- var reader = new FileReader();
- reader.readAsDataURL(data.blob());
- reader.onloadend = function () {
- console.log("Base64", reader.result);
- }
- //Here Writing a blob file to storage
- this.file.writeFile(this.file.externalRootDirectory, fileName, data.blob(), { replace: true })
- .then((success) => {
- console.log("File Writed Successfully", success);
- }).catch((err) => {
- console.log("Error While Wrinting File", err);
- });
- });
- }
- public _apiHeaderForImageURL() {
- let headers = new Headers({ 'Content-Type': 'image/jpeg' });
- headers.append('Authorization', 'Bearer ' + localStorage.getItem("token"));
- let options = new RequestOptions({ headers: headers, responseType: 3 });
- return options;
- }
The result comes an default image like this only.
pls help me to achieve this. Any help warmly accepted.
Iam doing long time stuff to achieve this still i cant achieve pls give some idea.
Is any other way is available to get user picture in ionic 3 using spfx?


Arutselvan MuthukannuRank #732 · 3.2K reputationPosted Jun 4, 2018, 8:26 AM EDT
Since you are using Ionic framework to create mobile app, you're not using SPFx I think. You should have created Azure AD app to work with this one. You can use graph API to retrieve the profile picture. Use the below endpoint to retrieve the profile picture.
https://graph.microsoft.com/v1.0/me/photo/$value
Make sure that you are getting the Access token for graph endpoint using OAuth.
Hari Murugesan42 reputationPosted Jun 1, 2018, 2:10 AM EDT
Hari Murugesan42 reputationPosted Jun 5, 2018, 12:26 AM EDT
Nanddeep NachanRank #38 · 35.2K reputationPosted May 31, 2018, 4:38 AM EDT
Nanddeep NachanRank #38 · 35.2K reputationPosted Jun 4, 2018, 1:12 AM EDT
Nanddeep NachanRank #38 · 35.2K reputationPosted Jun 4, 2018, 9:07 PM EDT