⬆️ Updated to v4 of oauth2
This commit is contained in:
parent
0d298614c9
commit
861b8524ed
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
.idea
|
||||||
|
|
||||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
|
34
README.md
34
README.md
@ -2,30 +2,30 @@
|
|||||||
|
|
||||||
> Using Gin framework implementation OAuth 2.0 services
|
> 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
|
## Quick Start
|
||||||
|
|
||||||
### Download and install
|
### Download and install
|
||||||
|
|
||||||
``` bash
|
```bash
|
||||||
$ go get -u github.com/go-oauth2/gin-server
|
$ go get -u github.com/go-oauth2/gin-server
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create file `server.go`
|
### Create file `server.go`
|
||||||
|
|
||||||
``` go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-oauth2/gin-server"
|
"gitee.ltd/go-oauth2/gin-server"
|
||||||
"gopkg.in/oauth2.v3/manage"
|
"github.com/go-oauth2/oauth2/v4/manage"
|
||||||
"gopkg.in/oauth2.v3/models"
|
"github.com/go-oauth2/oauth2/v4/models"
|
||||||
"gopkg.in/oauth2.v3/server"
|
"github.com/go-oauth2/oauth2/v4/server"
|
||||||
"gopkg.in/oauth2.v3/store"
|
"github.com/go-oauth2/oauth2/v4/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -74,7 +74,7 @@ func main() {
|
|||||||
|
|
||||||
### Build and run
|
### Build and run
|
||||||
|
|
||||||
``` bash
|
```bash
|
||||||
$ go build server.go
|
$ go build server.go
|
||||||
$ ./server
|
$ ./server
|
||||||
```
|
```
|
||||||
@ -87,7 +87,7 @@ $ ./server
|
|||||||
http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=000000&client_secret=999999&scope=read
|
http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=000000&client_secret=999999&scope=read
|
||||||
```
|
```
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{
|
{
|
||||||
"access_token": "AJPNSQO2PCITABYX0RFLWG",
|
"access_token": "AJPNSQO2PCITABYX0RFLWG",
|
||||||
"expires_in": 7200,
|
"expires_in": 7200,
|
||||||
@ -102,7 +102,7 @@ http://localhost:9096/oauth2/token?grant_type=client_credentials&client_id=00000
|
|||||||
http://localhost:9096/api/test?access_token=AJPNSQO2PCITABYX0RFLWG
|
http://localhost:9096/api/test?access_token=AJPNSQO2PCITABYX0RFLWG
|
||||||
```
|
```
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{
|
{
|
||||||
"ClientID": "000000",
|
"ClientID": "000000",
|
||||||
"UserID": "",
|
"UserID": "",
|
||||||
@ -126,9 +126,9 @@ http://localhost:9096/api/test?access_token=AJPNSQO2PCITABYX0RFLWG
|
|||||||
Copyright (c) 2016 Lyric
|
Copyright (c) 2016 Lyric
|
||||||
```
|
```
|
||||||
|
|
||||||
[License-Url]: http://opensource.org/licenses/MIT
|
[license-url]: http://opensource.org/licenses/MIT
|
||||||
[License-Image]: https://img.shields.io/npm/l/express.svg
|
[license-image]: https://img.shields.io/npm/l/express.svg
|
||||||
[ReportCard-Url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
|
[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/gin-server
|
||||||
[ReportCard-Image]: https://goreportcard.com/badge/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-url]: https://godoc.org/github.com/go-oauth2/gin-server
|
||||||
[GoDoc-Image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg
|
[godoc-image]: https://godoc.org/github.com/go-oauth2/gin-server?status.svg
|
@ -1,8 +1,8 @@
|
|||||||
package ginserver
|
package ginserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gopkg.in/oauth2.v3"
|
"github.com/go-oauth2/oauth2/v4"
|
||||||
"gopkg.in/oauth2.v3/server"
|
"github.com/go-oauth2/oauth2/v4/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetTokenType token type
|
// SetTokenType token type
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
ginserver "gin-server"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"gitee.ltd/go-oauth2/gin-server"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-oauth2/gin-server"
|
"github.com/go-oauth2/oauth2/v4/manage"
|
||||||
"gopkg.in/oauth2.v3/manage"
|
"github.com/go-oauth2/oauth2/v4/models"
|
||||||
"gopkg.in/oauth2.v3/models"
|
"github.com/go-oauth2/oauth2/v4/server"
|
||||||
"gopkg.in/oauth2.v3/server"
|
"github.com/go-oauth2/oauth2/v4/store"
|
||||||
"gopkg.in/oauth2.v3/store"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user