Skip to content

Commit

Permalink
Merge pull request #12 from visoft/master
Browse files Browse the repository at this point in the history
Updated to v4 of oauth2
  • Loading branch information
LyricTian authored Jun 7, 2022
2 parents 0d29861 + e37c2ae commit 797d567
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

> Using Gin framework implementation OAuth 2.0 services
[![License][License-Image]][License-Url] [![ReportCard][ReportCard-Image]][ReportCard-Url] [![GoDoc][GoDoc-Image]][GoDoc-Url]
[![License][license-image]][license-url] [![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url]

## Quick Start

### Download and install

``` bash
```bash
$ go get -u github.com/go-oauth2/gin-server
```

### Create file `server.go`

``` go
```go
package main

import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/go-oauth2/gin-server"
"gopkg.in/oauth2.v3/manage"
"gopkg.in/oauth2.v3/models"
"gopkg.in/oauth2.v3/server"
"gopkg.in/oauth2.v3/store"
"github.com/go-oauth2/oauth2/v4/manage"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/go-oauth2/oauth2/v4/server"
"github.com/go-oauth2/oauth2/v4/store"
)

func main() {
Expand Down Expand Up @@ -74,7 +74,7 @@ func main() {

### Build and run

``` bash
```bash
$ go build server.go
$ ./server
```
Expand All @@ -87,12 +87,12 @@ $ ./server
http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=000000&client_secret=999999&scope=read
```

``` json
```json
{
"access_token": "AJPNSQO2PCITABYX0RFLWG",
"expires_in": 7200,
"scope": "read",
"token_type": "Bearer"
"access_token": "AJPNSQO2PCITABYX0RFLWG",
"expires_in": 7200,
"scope": "read",
"token_type": "Bearer"
}
```

Expand All @@ -102,21 +102,21 @@ http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=00000
http://localhost:9096/api/test?access_token=AJPNSQO2PCITABYX0RFLWG
```

``` json
```json
{
"ClientID": "000000",
"UserID": "",
"RedirectURI": "",
"Scope": "read",
"Code": "",
"CodeCreateAt": "0001-01-01T00:00:00Z",
"CodeExpiresIn": 0,
"Access": "AJPNSQO2PCITABYX0RFLWG",
"AccessCreateAt": "2016-11-29T09:00:52.617250916+08:00",
"AccessExpiresIn": 7200000000000,
"Refresh": "",
"RefreshCreateAt": "0001-01-01T00:00:00Z",
"RefreshExpiresIn": 0
"ClientID": "000000",
"UserID": "",
"RedirectURI": "",
"Scope": "read",
"Code": "",
"CodeCreateAt": "0001-01-01T00:00:00Z",
"CodeExpiresIn": 0,
"Access": "AJPNSQO2PCITABYX0RFLWG",
"AccessCreateAt": "2016-11-29T09:00:52.617250916+08:00",
"AccessExpiresIn": 7200000000000,
"Refresh": "",
"RefreshCreateAt": "0001-01-01T00:00:00Z",
"RefreshExpiresIn": 0
}
```

Expand All @@ -126,9 +126,9 @@ http://localhost:9096/api/test?access_token=AJPNSQO2PCITABYX0RFLWG
Copyright (c) 2016 Lyric
```

[License-Url]: http://opensource.org/licenses/MIT
[License-Image]: https://img.shields.io/npm/l/express.svg
[ReportCard-Url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
[ReportCard-Image]: https://goreportcard.com/badge/github.com/go-oauth2/gin-server
[GoDoc-Url]: https://godoc.org/github.com/go-oauth2/gin-server
[GoDoc-Image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg
[license-url]: http://opensource.org/licenses/MIT
[license-image]: https://img.shields.io/npm/l/express.svg
[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
[reportcard-image]: https://goreportcard.com/badge/github.com/go-oauth2/gin-server
[godoc-url]: https://godoc.org/github.com/go-oauth2/gin-server
[godoc-image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ginserver

import (
"gopkg.in/oauth2.v3"
"gopkg.in/oauth2.v3/server"
"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/server"
)

// SetTokenType token type
Expand Down
9 changes: 5 additions & 4 deletions examples/server.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package main

import (
ginserver "gin-server"
"net/http"

"github.com/gin-gonic/gin"
"github.com/go-oauth2/gin-server"
"gopkg.in/oauth2.v3/manage"
"gopkg.in/oauth2.v3/models"
"gopkg.in/oauth2.v3/server"
"gopkg.in/oauth2.v3/store"
"github.com/go-oauth2/oauth2/v4/manage"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/go-oauth2/oauth2/v4/server"
"github.com/go-oauth2/oauth2/v4/store"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sync"

"github.com/gin-gonic/gin"
"gopkg.in/oauth2.v3"
"gopkg.in/oauth2.v3/server"
"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/server"
)

var (
Expand Down

0 comments on commit 797d567

Please sign in to comment.