Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
KimTaeO committed Nov 7, 2023
1 parent afdda7d commit 6609c07
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,123 @@
# gauth-go

---

[![Go Reference](https://pkg.go.dev/badge/github.com/onee-only/gauth-go.svg)](https://pkg.go.dev/github.com/onee-only/gauth-go)
[![codecov](https://codecov.io/gh/onee-only/gauth-go/graph/badge.svg?token=CG5WOHFTMX)](https://codecov.io/gh/onee-only/gauth-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/onee-only/gauth-go)](https://goreportcard.com/report/github.com/onee-only/gauth-go)

Package gauth is go version of gauth sdk.

## Description

---

광주소프트웨어 마이스터고등학교의 통합 계정 관리 서비스인 ```GAuth``````Golang```으로 더 손쉽게 사용할 수 있도록 만들어진 라이브러리 입니다

## Installation

```
go get -u https://github.com/onee-only/gauth-go
```

## How To Use

### Client Initialization
```go
package main

import(
"github.com/onee-only/gauth-go"
)

func main() {
client := gauth.NewDefaultClient(gauth.ClientOpts{
ClientID: "clientID",
ClientSecret: "clientSecret",
RedirectURI: "localhost:8080",
})
}
```

### code 발급
```go
package main

import (
"log"

"github.com/onee-only/gauth-go"
)

func issueCode(client *gauth.Client) {
code, err := client.IssueCode("email", "password")
if err != nil {
// You shouldn't use panic in your code.
panic(err)
}
log.Println(code)
}
```

### Token 발급

```go
package main

import (
"log"

"github.com/onee-only/gauth-go"
)

func issueToken(client *gauth.Client) {
accessToken, refreshToken, err := client.IssueToken("code")
if err != nil {
// You shouldn't use panic in your code.
panic(err)
}
log.Println(accessToken)
log.Println(refreshToken)
}
```

### Token 재발급
```go
package main

import (
"log"

"github.com/onee-only/gauth-go"
)

func reIssueToken(client *gauth.Client) {
access, refresh, err := client.ReIssueToken("refreshToken")
if err != nil {
// You shouldn't use panic in your code.
panic(err)
}
log.Println(access)
log.Println(refresh)
}
```

### 유저 정보 가져오기
```go
package main

import (
"log"

"github.com/onee-only/gauth-go"
)

func getUserInfo(client *gauth.Client) {
info, err := client.GetUserInfo("accessToken")
if err != nil {
// You shouldn't use panic in your code.
panic(err)
}
log.Println(info)
}
```

0 comments on commit 6609c07

Please sign in to comment.