0

I am using Next Auth and Prisma adaptor but the user information i get is just there email and name, not there actual github username or any other type of info, this is what the prisma schema looks like

datasource db {
  provider             = "mysql"
  url                  = env("DATABASE_URL")
  referentialIntegrity = "prisma"
}

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["referentialIntegrity"]
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String? @db.Text
  access_token      String? @db.Text
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String? @db.Text
  session_state     String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  accounts      Account[]
  sessions      Session[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

What i want to do is be able to fetch the signed in users github username and github related repos, but i dont want to hard code my username, but use the signed in users information to fetch there stuff, how would i do this, am i abke to use there token to access somehow to fetch this information ?

juliomalves
  • 42,130
  • 20
  • 150
  • 146
user18371666
  • 71
  • 1
  • 8
  • 2
    I assume that you're using next-auth, this [page](https://next-auth.js.org/configuration/providers/oauth#override-default-options) shows how you can override the default `profile` data returned from any provider, just tweak it to your needs. This [page](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/github.ts) shows the the default `GithubProfile` that next-auth gets. If you're confused about how to inplement this I can help you. – mocherfaoui Aug 06 '22 at 01:14
  • The repo is https://github.com/UmbrellaCrow612/Github – user18371666 Aug 09 '22 at 07:59
  • first, what do you want to do with an user's repos? do you want to take an action on the repo or just list its information? if its the latter, you can get the logged-in user's github username and try `https://api.github.com/users/{username}/repos` to get the user's public repos – mocherfaoui Aug 09 '22 at 18:18
  • 1
    its okay i have managed to figure it out thanks for the help – user18371666 Aug 10 '22 at 09:31

0 Answers0