How the heck do I give authentication to RequestAsync?

How do I send authorization throughh request async?

image

My code

local url = "https://api.github.com/user/repos"

local call = HttpService:RequestAsync({
   Url = url,
   Headers = {
      ["Content-Type"] = "application/json",
      ["Authorization"] = "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"
   },
   Method = "GET"
})

print(HttpService:JSONDecode(call.Body))

Maybe try PostAsync? Not sure because I never use HttpService. Also consider censoring the authorization token…?

Eh its fine man i can just generate new one, also I check the devhub and it said it recommends using request async over post, also im not even sure how to give it authenticaton either

ALright i finally figured it out!

so I dont know much about RESt api and stuff like that but i just had to specifiy the token, Bearer in front of my key

So putting the word Bearer before the auth key fixed your problem? Where did you find this out? Like, how did you come to that conclusion? I also don’t use github because it’s too confusing for me, if maybe that is a github thing.

Or, did removing Bearer fix your problem? It would make more sense, but it wasn’t there in the first image you sent of the auth key, so it can’t be.

Did removing the Content-Type value solve the issue?

I don’t have a problem similar to this, but it’s always good for other people to know what solved your issue, because maybe they have the problem you had.

Honeslty I was just scouring online forums and stackoverflow and youtube, and they were all using Bearer token and then it was also in the github api so I just threw it in front and it WORKED!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.