cancel
Showing results for 
Search instead for 
Did you mean: 

How to get user's avatar profile picture

Anonymous
Not applicable
Hello!

I've managed to obtain the user profile picture url with a S2S REST request following this thread. Is there a similar way to get the user's avatar profile picture? (I'm refering to the avatar picture that appears in the user profile)

Thanks in advance!


3 REPLIES 3

myBadStudios
Protege
Here's how I do it in Unity...





Texture2D player_avatar;
void Start()
{
if ( XRSettings.loadedDeviceName == "Oculus" )
{
Core.AsyncInitialize();
Entitlements.IsUserEntitledToApplication().OnComplete( EntitlementCallback );
}
}

void EntitlementCallback( Message msg )
{
if ( msg.IsError )
{
Debug.LogError( "You are NOT entitled to use this app." );
UnityEngine.Application.Quit();
}
else
{
Users.GetLoggedInUser().OnComplete( GetLoggedInUserCallback );
Request.RunCallbacks();
}
}

async void GetLoggedInUserCallback( Message message )
{
Avatar = Instantiate( Resources.Load("MyCustomPrefab"));
Avatar.StartWithControllers = true;
Avatar.oculusUserID = message.Data.ID.ToString();
player_avatar = await FetchPlayerImage( message.Data.ImageURL );
}

async Task FetchPlayerImage( string url )
{
url = url.Trim();
if ( !string.IsNullOrEmpty( url ) )
{
WWW w = new WWW( url );
while ( !w.isDone )
await Task.Delay( 100 );
if ( string.IsNullOrEmpty( w.error ) )
return w.texture;
else
Debug.LogWarning( w.error );
}
return null;
}

Anonymous
Not applicable


Hi,

I'll forward this to our platform SDK team and see if they can offer guidance on whether this is exposed behavior or road-mapped for the future.

EDIT:

You can currently retrieve a user's avatar profile picture URI using this:

https://graph.oculus.com/<userID>?access_token=<token>&fields=avatar_v2{avatar_image{uri}}


and by using the below
if you are still using older (deprecated) avatars:

avatar{avatar_image{uri}}



This worked for me! Thank you so much 🙂

Florian.BRINK
Protege

Hi guys, the following url returns a json containing only the user id, and no image url. I'm guessing this method is now outdated...?

 

Are you aware of any other way to get the avatar image by any chance?