Skip to content

Commit

Permalink
fix: add id_token and support auth header (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer authored and nomeguy committed Nov 28, 2021
1 parent 7923bff commit e888ff8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controllers/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func (c *ApiController) GetOAuthToken() {
clientSecret := c.Input().Get("client_secret")
code := c.Input().Get("code")

if clientId == "" && clientSecret == "" {
clientId, clientSecret, _ = c.Ctx.Request.BasicAuth()
}

c.Data["json"] = object.GetOAuthToken(grantType, clientId, clientSecret, code)
c.ServeJSON()
}
2 changes: 2 additions & 0 deletions object/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Token struct {

type TokenWrapper struct {
AccessToken string `json:"access_token"`
IdToken string `json:"id_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
Scope string `json:"scope"`
Expand Down Expand Up @@ -275,6 +276,7 @@ func GetOAuthToken(grantType string, clientId string, clientSecret string, code

tokenWrapper := &TokenWrapper{
AccessToken: token.AccessToken,
IdToken: token.AccessToken,
TokenType: token.TokenType,
ExpiresIn: token.ExpiresIn,
Scope: token.Scope,
Expand Down

0 comments on commit e888ff8

Please sign in to comment.