fix: add id_token and support auth header (#338)

This commit is contained in:
Товарищ программист 2021-11-28 16:19:42 +08:00 committed by Gucheng Wang
parent 7923bffa6d
commit e888ff8475
2 changed files with 6 additions and 0 deletions

View File

@ -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()
}

View File

@ -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"`
@ -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,