@@ -146,12 +146,18 @@ when GOIC has new features.
146
146
147
147
> The example and discussion here assume ` localhost ` domain so adjust that accordingly for your domains.
148
148
149
+ ### Signing out
150
+
151
+ For signing out you need to manually invoke ` g.SignOut() ` from within http context. See the [ API] ( #signout ) below.
152
+
149
153
---
150
154
## GOIC API
151
155
152
156
GOIC supports full end-to-end for Authorization Code Flow, however if you want to manually interact, here's summary of API:
153
157
154
- #### Check Provider
158
+ #### Supports
159
+
160
+ Use it to check if a provider is supported.
155
161
156
162
``` go
157
163
g := goic.New (" /auth/o8" , false )
@@ -161,7 +167,7 @@ g.Supports("abc") // true
161
167
g.Supports (" xyz" ) // false
162
168
```
163
169
164
- #### Refresh Token
170
+ #### RefreshToken
165
171
166
172
Use it to request Access token by using refresh token.
167
173
@@ -173,9 +179,9 @@ tok, err := g.RefreshToken(t)
173
179
// Do something with tok.AccessToken
174
180
```
175
181
176
- #### Auth Request
182
+ #### RequestAuth
177
183
178
- Manually request authentication from OpenID Provider.
184
+ Manually request authentication from OpenID Provider. Must be called from within http context.
179
185
180
186
``` go
181
187
g := goic.New (" /auth/o8" , false )
@@ -193,7 +199,7 @@ redir := "https://localhost/auth/o8/" + p.Name
193
199
err := g.RequestAuth (p, state, nonce, redir, res, req)
194
200
```
195
201
196
- #### Authentication
202
+ #### Authenticate
197
203
198
204
Manually attempt to authenticate after the request comes back from OpenID Provider.
199
205
@@ -211,9 +217,10 @@ redir := "https://localhost/auth/o8/" + p.Name
211
217
tok , err := g.Authenticate (p, code, nonce, redir)
212
218
```
213
219
214
- ### Userinfo
220
+ #### Userinfo
215
221
216
222
Manually request Userinfo by using the token returned by Authentication above.
223
+
217
224
``` go
218
225
g := goic.New (" /auth/o8" , false )
219
226
p := g.NewProvider (" abc" , " ..." ).WithCredential (" ..." , " ..." )
@@ -223,6 +230,21 @@ user := g.UserInfo(tok)
223
230
err := user.Error
224
231
```
225
232
233
+ #### SignOut
234
+
235
+ Use it to sign out the user from OpenID Provider. Must be called from within http context.
236
+ Ideally, you would clear the session and logout user from your own system first and then invoke SignOut.
237
+
238
+ ``` go
239
+ g := goic.New (" /auth/o8" , false )
240
+ p := g.NewProvider (" abc" , " ..." ).WithCredential (" ..." , " ..." )
241
+ // ...
242
+ tok := &goic.Token {AccessToken: " current session token" , Provider : p.Name }
243
+ err := g.SignOut (tok, " http://some/preconfigured/redir/uri" , res, req)
244
+ // redir uri is optional
245
+ err := g.SignOut (tok, " " , res, req)
246
+ ```
247
+
226
248
---
227
249
### Demo
228
250
0 commit comments