Skip to content

Commit 797d567

Browse files
authored
Merge pull request #12 from visoft/master
Updated to v4 of oauth2
2 parents 0d29861 + e37c2ae commit 797d567

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

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

77
## Quick Start
88

99
### Download and install
1010

11-
``` bash
11+
```bash
1212
$ go get -u github.com/go-oauth2/gin-server
1313
```
1414

1515
### Create file `server.go`
1616

17-
``` go
17+
```go
1818
package main
1919

2020
import (
2121
"net/http"
2222

2323
"github.com/gin-gonic/gin"
2424
"github.com/go-oauth2/gin-server"
25-
"gopkg.in/oauth2.v3/manage"
26-
"gopkg.in/oauth2.v3/models"
27-
"gopkg.in/oauth2.v3/server"
28-
"gopkg.in/oauth2.v3/store"
25+
"github.com/go-oauth2/oauth2/v4/manage"
26+
"github.com/go-oauth2/oauth2/v4/models"
27+
"github.com/go-oauth2/oauth2/v4/server"
28+
"github.com/go-oauth2/oauth2/v4/store"
2929
)
3030

3131
func main() {
@@ -74,7 +74,7 @@ func main() {
7474

7575
### Build and run
7676

77-
``` bash
77+
```bash
7878
$ go build server.go
7979
$ ./server
8080
```
@@ -87,12 +87,12 @@ $ ./server
8787
http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=000000&client_secret=999999&scope=read
8888
```
8989

90-
``` json
90+
```json
9191
{
92-
"access_token": "AJPNSQO2PCITABYX0RFLWG",
93-
"expires_in": 7200,
94-
"scope": "read",
95-
"token_type": "Bearer"
92+
"access_token": "AJPNSQO2PCITABYX0RFLWG",
93+
"expires_in": 7200,
94+
"scope": "read",
95+
"token_type": "Bearer"
9696
}
9797
```
9898

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

105-
``` json
105+
```json
106106
{
107-
"ClientID": "000000",
108-
"UserID": "",
109-
"RedirectURI": "",
110-
"Scope": "read",
111-
"Code": "",
112-
"CodeCreateAt": "0001-01-01T00:00:00Z",
113-
"CodeExpiresIn": 0,
114-
"Access": "AJPNSQO2PCITABYX0RFLWG",
115-
"AccessCreateAt": "2016-11-29T09:00:52.617250916+08:00",
116-
"AccessExpiresIn": 7200000000000,
117-
"Refresh": "",
118-
"RefreshCreateAt": "0001-01-01T00:00:00Z",
119-
"RefreshExpiresIn": 0
107+
"ClientID": "000000",
108+
"UserID": "",
109+
"RedirectURI": "",
110+
"Scope": "read",
111+
"Code": "",
112+
"CodeCreateAt": "0001-01-01T00:00:00Z",
113+
"CodeExpiresIn": 0,
114+
"Access": "AJPNSQO2PCITABYX0RFLWG",
115+
"AccessCreateAt": "2016-11-29T09:00:52.617250916+08:00",
116+
"AccessExpiresIn": 7200000000000,
117+
"Refresh": "",
118+
"RefreshCreateAt": "0001-01-01T00:00:00Z",
119+
"RefreshExpiresIn": 0
120120
}
121121
```
122122

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

129-
[License-Url]: http://opensource.org/licenses/MIT
130-
[License-Image]: https://img.shields.io/npm/l/express.svg
131-
[ReportCard-Url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
132-
[ReportCard-Image]: https://goreportcard.com/badge/github.com/go-oauth2/gin-server
133-
[GoDoc-Url]: https://godoc.org/github.com/go-oauth2/gin-server
134-
[GoDoc-Image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg
129+
[license-url]: http://opensource.org/licenses/MIT
130+
[license-image]: https://img.shields.io/npm/l/express.svg
131+
[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
132+
[reportcard-image]: https://goreportcard.com/badge/github.com/go-oauth2/gin-server
133+
[godoc-url]: https://godoc.org/github.com/go-oauth2/gin-server
134+
[godoc-image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package ginserver
22

33
import (
4-
"gopkg.in/oauth2.v3"
5-
"gopkg.in/oauth2.v3/server"
4+
"github.com/go-oauth2/oauth2/v4"
5+
"github.com/go-oauth2/oauth2/v4/server"
66
)
77

88
// SetTokenType token type

examples/server.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package main
22

33
import (
4+
ginserver "gin-server"
45
"net/http"
56

67
"github.com/gin-gonic/gin"
78
"github.com/go-oauth2/gin-server"
8-
"gopkg.in/oauth2.v3/manage"
9-
"gopkg.in/oauth2.v3/models"
10-
"gopkg.in/oauth2.v3/server"
11-
"gopkg.in/oauth2.v3/store"
9+
"github.com/go-oauth2/oauth2/v4/manage"
10+
"github.com/go-oauth2/oauth2/v4/models"
11+
"github.com/go-oauth2/oauth2/v4/server"
12+
"github.com/go-oauth2/oauth2/v4/store"
1213
)
1314

1415
func main() {

server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"sync"
66

77
"github.com/gin-gonic/gin"
8-
"gopkg.in/oauth2.v3"
9-
"gopkg.in/oauth2.v3/server"
8+
"github.com/go-oauth2/oauth2/v4"
9+
"github.com/go-oauth2/oauth2/v4/server"
1010
)
1111

1212
var (

0 commit comments

Comments
 (0)