oauth2/client/revokation.go

42 lines
844 B
Go

package client
import (
"fmt"
"net/url"
"somehole.com/service/oauth2/session"
)
type TokenRevokationUrl struct {
*Client
*session.Session
TokenChoice session.TokenChoice
}
func NewTokenRevokationUrl(client *Client, id session.SessionId, choice session.TokenChoice) (url *TokenRevokationUrl, err error) {
ses, ok := client.sessions[id]
if !ok {
err = fmt.Errorf("no session found")
}
url = &TokenRevokationUrl{
Client: client,
Session: ses,
TokenChoice: choice,
}
return
}
func (t *TokenRevokationUrl) Url() *url.URL {
v := url.Values{
"token": {t.GetToken(t.TokenChoice)},
"token_type_hint": {t.TokenChoice.String()},
}
return &url.URL{
Scheme: "https",
User: url.UserPassword(t.ClientId, t.ClientSecret),
Host: t.Host,
Path: t.TokenUrlPath,
RawQuery: v.Encode(),
}
}