Ask coding questions

← Back to all posts
How to get user image
h
ch1ck3n (1622)

I'm making a project in django, and i'm using replit auth. when authed i want to display the user picture to the client but I can't figure out how to. is there a HTTP header for the user picture or do I just have to scrape it off the replit page (I really don't want to do some scraping)

Answered by 19ecal (230) [earned 5 cycles]
View Answer
Comments
hotnewtop
19ecal (230)

You can request to https://replit.com/data/profiles/<user> and parse the JSON returned, then get data["icon"]["url"]

19ecal (230)
import requests, json
r=requests.get("https://replit.com/data/profiles/ch1ck3n").text
r=json.loads(r)
print(r["icon"]["url"])
19ecal (230)

That returns the url for their profile picture, or None if they have a default one

ch1ck3n (1622)

@19ecal :O thank you so much! which post should i mark as correct

ryanbrwr (33)

There currently doesn't seem to be a header to get the user picture. I read in one of the comment sections that os.getenv("REPL_IMAGE") gives the URL. Here's the link to the thread: https://replit.com/talk/learn/Authenticating-users-with-Replit-Auth/23460 . Hope this helps!

ch1ck3n (1622)

@ryanbrwr But doesn't
that get the repl owner's pfp?