Skip to content

Commit 9cf00c0

Browse files
committed
docs: add revocation section and code snippet
1 parent b7c04c5 commit 9cf00c0

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

README.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ when GOIC has new features.
150150
For signing out you need to manually invoke `g.SignOut()` from within http context. See the [API](#signout) below.
151151
There is also a working [example](./examples/all.go). Note that not all Providers support signing out.
152152

153+
### Revocation
154+
155+
To revoke a token manually, invoke `g.RevokeToken()` from any context. See the [API](#revoketoken) below.
156+
There is also a working [example](./examples/all.go). Note that not all Providers support signing out.
157+
153158
---
154159
## GOIC API
155160

@@ -167,18 +172,6 @@ g.Supports("abc") // true
167172
g.Supports("xyz") // false
168173
```
169174

170-
#### RefreshToken
171-
172-
Use it to request Access token by using refresh token.
173-
174-
```go
175-
g := goic.New("/auth/o8", false)
176-
// ... add providers
177-
t := &goic.Token{RefreshToken: "your refresh token", Provider: goic.Microsoft.Name}
178-
tok, err := g.RefreshToken(t)
179-
// Do something with tok.AccessToken
180-
```
181-
182175
#### RequestAuth
183176

184177
Manually request authentication from OpenID Provider. Must be called from within http context.
@@ -217,6 +210,18 @@ redir := "https://localhost/auth/o8/" + p.Name
217210
tok, err := g.Authenticate(p, code, nonce, redir)
218211
```
219212

213+
#### RefreshToken
214+
215+
Use it to request Access token by using refresh token.
216+
217+
```go
218+
g := goic.New("/auth/o8", false)
219+
// ... add providers
220+
t := &goic.Token{RefreshToken: "your refresh token", Provider: goic.Microsoft.Name}
221+
tok, err := g.RefreshToken(t)
222+
// Do something with tok.AccessToken
223+
```
224+
220225
#### Userinfo
221226

222227
Manually request Userinfo by using the token returned by Authentication above.
@@ -245,6 +250,18 @@ err := g.SignOut(tok, "http://some/preconfigured/redir/uri", res, req)
245250
err := g.SignOut(tok, "", res, req)
246251
```
247252

253+
#### RevokeToken
254+
255+
Use it to revoke the token so that is incapacitated.
256+
257+
```go
258+
g := goic.New("/auth/o8", false)
259+
p := g.NewProvider("abc", "...").WithCredential("...", "...")
260+
// ...
261+
tok := &goic.Token{AccessToken: "current session token", Provider: p.Name}
262+
err := g.RevokeToken(tok)
263+
```
264+
248265
---
249266
### Demo
250267

0 commit comments

Comments
 (0)