Back

how to get user's access token after OAuth

  • 0
  • Accounts
  • Web
Dakshie
11 Jun, 2023, 14:50

I want to access user's github info

(I tried using this, after creating a session https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user but it didn't work, it does return a user but its not equal to the current user, not really sure why;-; So I wana try other approach)

TL;DR
The user is trying to figure out how to get the user's access token after OAuth. They are discussing different ideas and potential solutions, but there is no definitive answer or solution provided in the thread.
safwan
11 Jun, 2023, 14:57

There can be multiple reasons why that doesn't work, one of them being that Appwrite handles the OAuth, not you, if that makes sense.

That being said, what exact information do you want from the user's github?

safwan
11 Jun, 2023, 14:58

I'm not sure how to go about it just yet, but maybe more info will help me think of something.

Dakshie
11 Jun, 2023, 14:59

I just need the username, I have a function that takes github username as input and returns info like languages used in repos etc

safwan
11 Jun, 2023, 15:02

Let me look into this and see if I find something

Dakshie
11 Jun, 2023, 19:34

hey did u find anything;-;

safwan
12 Jun, 2023, 07:30

Unfortunately, no. I've asked the team to take a look, and if there's any findings, I'll be sure to post them here

Guille
12 Jun, 2023, 13:27

At the moment, Isn't possible to get any other data, we just get the email:

https://github.com/appwrite/appwrite/blob/master/src/Appwrite/Auth/OAuth2/Github.php#L166-L184

If you are using a selfhost version you can override the github logic and update to do what you want

Drake
12 Jun, 2023, 14:39

did you try to fetch the OAuth2 session?

loup
26 Jun, 2023, 14:52

Hi, Im looking for the same think. I want to add username for each Appwrite user but with Oauth idk how manage that because we cant add username (with createDocument....)

Dakshie
26 Jun, 2023, 15:00

How are you getting the username?

Dakshie
26 Jun, 2023, 15:02

why can't you add it with createDocument() after user signs in with OAuth?

loup
26 Jun, 2023, 18:10

But i dont want to get the username from github because if the github username is already used by an user in my Appwrite instance that gonna be a problem

loup
26 Jun, 2023, 18:11

The only way that ive found to solve the problem is when u login, there is a check if user.username exist. If not, a modal open when to let the user add his username

Dakshie
26 Jun, 2023, 19:32

Yeah, I did the same thing

loup
26 Jun, 2023, 19:41

ive got a better idea

loup
26 Jun, 2023, 19:41

Because the modal can be deleted in F12 etc...

loup
26 Jun, 2023, 19:41

Ive check how Twitter managed the signup with OAuth

loup
26 Jun, 2023, 19:43

And they create a default username based on the name. Like if the name is Brad Pitt, the username gonna be bradpitt, or bradpitt1, or bradpitt4684, etc...

loup
26 Jun, 2023, 19:44

So my idea is to create an Appwrite Function triggered by user.*.create and inside check is a document with username exist on the user collection. If true (case : signup with email) return. If false (case: signup OAuth), add document with a username based on the user Name

loup
26 Jun, 2023, 23:33

Ive a function who generate username based on the name of the user. Ive post my function here : https://discord.com/channels/564160730845151244/1122954494909632542/1123032987009826870

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more