Ask coding questions

← Back to all posts
Getting user pfp from repl auth
StringentDev (223)

Hey guys (why do i always open my posts with this phrase now),
The Foxglovedev team is making a chatting webapp using repl auth (Nomad) using flightcss (which i have been writing).

we only just started using it but nothing gives all the headers for repl auth.

are there headers to find the profile picture location using repl auth?

if not how can we use the web scraper as every other repl looks like they uglified it.

people who i know have contributed:
@AdCharity
@Codeteacher
@Lethdev2019
@WYLDYR
@CodingAndMemes

All help is welcome.

Comments
hotnewtop
Coder100 (18071)

Make a POST request to repl.it/graphql. The headers should be:

{
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "X-Requested-With": "any",
    "Referrer": "https://repl.it",
    "Origin": "https://repl.it"
  }

The body should be a stringifed version of:

query: "{userByUsername(username: [username here]) {image}}"

Now you will have the URL of the user's profile picture. Be sure to actually replace [username here] with the given username.

hint: add karma to view cycles!

StringentDev (223)

well, we have the username - but we - i do not think - have ever used graphql @Coder100

StringentDev (223)

so how do we use that to get the avatar? @Coder100

StringentDev (223)

seems that it kept on failing, so we cannot implement that solution. @Coder100

StringentDev (223)

the post request headers. @Coder100

Coder100 (18071)

Using repl.it authentication alone, all you are able to get is:

  • Username
  • ID
  • Roles

With graphQL, you will be able to get the profile picture.

mkhoi (299)

@Coder100 lol, why do you make multiple comments when you can just edit one comment

mkhoi (299)

@Coder100 wtf that was lighting fast

TalinSharma (77)

Hi... I am confused... I did this post request with jquery but for some reason it doesn't alert anything at all...

  $.ajax({
    type: "POST",
    url: "https://replit.com/graphql",
    data: {
      headers: {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Accept-Encoding": "gzip, deflate, br",
        "Connection": "keep-alive",
        "X-Requested-With": "any",
        "Referrer": "https://repl.it",
        "Origin": "https://repl.it"
      },
      body: JSON.stringify({query: `{userByUsername(username:"TalinSharma") {image}}`})
    },
    success: (data) => {
      alert(data)
    },
    fail: () => {
      alert('fail')
    }
  })

@Coder100

Thanks!

TalinSharma (77)

So I changed the code but now it alerts Hello World!
and then Fail... Any idea what is wrong?

$.ajaxSetup({
  url:'https://replit.com/graphql',
	headers: {
		"Content-Type": "application/json",
		"Accept": "application/json",
		"Accept-Encoding": "gzip, deflate, br",
		"Connection": "keep-alive",
		"X-Requested-With": "any",
		"Referrer": "https://repl.it",
		"Origin": "https://repl.it"
	}
});

var ajax = $.post({data:{query: "{userByUsername(username: TalinSharma) {image, karma}}"}})

ajax.always(() => {
  alert('Hello World!')
})

ajax.fail(() => {
  alert('Fail')
})

@TalinSharma
@Coder100