Feat: impl oauth2 refresh token

pull/21/head
zijiren233 3 years ago
parent d3ced2c376
commit 12383adaa2

@ -49,6 +49,21 @@ func (c *GRPCClient) GetToken(ctx context.Context, code string) (*oauth2.Token,
}, nil
}
func (c *GRPCClient) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
resp, err := c.client.RefreshToken(ctx, &providerpb.RefreshTokenReq{
RefreshToken: tk,
})
if err != nil {
return nil, err
}
return &oauth2.Token{
AccessToken: resp.Token.AccessToken,
TokenType: resp.Token.TokenType,
RefreshToken: resp.Token.RefreshToken,
Expiry: time.Unix(resp.Token.Expiry, 0),
}, nil
}
func (c *GRPCClient) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
resp, err := c.client.GetUserInfo(ctx, &providerpb.GetUserInfoReq{
Token: &providerpb.Token{

@ -52,6 +52,10 @@ func (p *GiteeProvider) GetToken(ctx context.Context, code string) (*oauth2.Toke
return p.config.Exchange(ctx, code)
}
func (p *GiteeProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *GiteeProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://gitee.com/api/v5/user", nil)

@ -9,15 +9,9 @@ import (
type OAuth2Provider string
type TokenRefreshed struct {
Refreshed bool
Token *oauth2.Token
}
type UserInfo struct {
Username string
ProviderUserID uint
TokenRefreshed *TokenRefreshed
}
type Oauth2Option struct {
@ -31,6 +25,7 @@ type ProviderInterface interface {
Provider() OAuth2Provider
NewAuthURL(string) string
GetToken(context.Context, string) (*oauth2.Token, error)
RefreshToken(context.Context, string) (*oauth2.Token, error)
GetUserInfo(context.Context, *oauth2.Token) (*UserInfo, error)
}

@ -37,6 +37,11 @@ func (p *BaiduNetDiskProvider) NewAuthURL(state string) string {
func (p *BaiduNetDiskProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return p.config.Exchange(ctx, code)
}
func (p *BaiduNetDiskProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *BaiduNetDiskProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo&access_token=%s", tk.AccessToken), nil)

@ -40,6 +40,10 @@ func (p *BaiduProvider) GetToken(ctx context.Context, code string) (*oauth2.Toke
return p.config.Exchange(ctx, code)
}
func (p *BaiduProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *BaiduProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?access_token=%s", tk.AccessToken), nil)

@ -36,6 +36,10 @@ func (p *GiteeProvider) GetToken(ctx context.Context, code string) (*oauth2.Toke
return p.config.Exchange(ctx, code)
}
func (p *GiteeProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *GiteeProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://gitee.com/api/v5/user", nil)

@ -34,6 +34,10 @@ func (p *GithubProvider) GetToken(ctx context.Context, code string) (*oauth2.Tok
return p.config.Exchange(ctx, code)
}
func (p *GithubProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *GithubProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.github.com/user", nil)

@ -33,6 +33,10 @@ func (g *GitlabProvider) GetToken(ctx context.Context, code string) (*oauth2.Tok
return g.config.Exchange(ctx, code)
}
func (g *GitlabProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return g.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (g *GitlabProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := g.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://gitlab.com/api/v4/user", nil)

@ -34,6 +34,10 @@ func (g *GoogleProvider) GetToken(ctx context.Context, code string) (*oauth2.Tok
return g.config.Exchange(ctx, code)
}
func (g *GoogleProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return g.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (g *GoogleProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := g.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://www.googleapis.com/oauth2/v2/userinfo", nil)

@ -36,6 +36,10 @@ func (p *MicrosoftProvider) GetToken(ctx context.Context, code string) (*oauth2.
return p.config.Exchange(ctx, code)
}
func (p *MicrosoftProvider) RefreshToken(ctx context.Context, tk string) (*oauth2.Token, error) {
return p.config.TokenSource(ctx, &oauth2.Token{RefreshToken: tk}).Token()
}
func (p *MicrosoftProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://graph.microsoft.com/v1.0/me", nil)

@ -57,13 +57,5 @@ func (s *GRPCServer) GetUserInfo(ctx context.Context, req *providerpb.GetUserInf
Username: userInfo.Username,
ProviderUserId: uint64(userInfo.ProviderUserID),
}
if userInfo.TokenRefreshed != nil {
resp.TokenRefreshed = &providerpb.Token{
AccessToken: userInfo.TokenRefreshed.Token.AccessToken,
TokenType: userInfo.TokenRefreshed.Token.TokenType,
RefreshToken: userInfo.TokenRefreshed.Token.RefreshToken,
Expiry: userInfo.TokenRefreshed.Token.Expiry.Unix(),
}
}
return resp, nil
}

@ -201,6 +201,100 @@ func (x *Token) GetExpiry() int64 {
return 0
}
type RefreshTokenReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
}
func (x *RefreshTokenReq) Reset() {
*x = RefreshTokenReq{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RefreshTokenReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenReq) ProtoMessage() {}
func (x *RefreshTokenReq) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenReq.ProtoReflect.Descriptor instead.
func (*RefreshTokenReq) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{3}
}
func (x *RefreshTokenReq) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
type RefreshTokenResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
}
func (x *RefreshTokenResp) Reset() {
*x = RefreshTokenResp{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RefreshTokenResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenResp) ProtoMessage() {}
func (x *RefreshTokenResp) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenResp.ProtoReflect.Descriptor instead.
func (*RefreshTokenResp) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{4}
}
func (x *RefreshTokenResp) GetToken() *Token {
if x != nil {
return x.Token
}
return nil
}
type ProviderResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -212,7 +306,7 @@ type ProviderResp struct {
func (x *ProviderResp) Reset() {
*x = ProviderResp{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[3]
mi := &file_proto_provider_plugin_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -225,7 +319,7 @@ func (x *ProviderResp) String() string {
func (*ProviderResp) ProtoMessage() {}
func (x *ProviderResp) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[3]
mi := &file_proto_provider_plugin_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -238,7 +332,7 @@ func (x *ProviderResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use ProviderResp.ProtoReflect.Descriptor instead.
func (*ProviderResp) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{3}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{5}
}
func (x *ProviderResp) GetName() string {
@ -259,7 +353,7 @@ type NewAuthURLReq struct {
func (x *NewAuthURLReq) Reset() {
*x = NewAuthURLReq{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[4]
mi := &file_proto_provider_plugin_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -272,7 +366,7 @@ func (x *NewAuthURLReq) String() string {
func (*NewAuthURLReq) ProtoMessage() {}
func (x *NewAuthURLReq) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[4]
mi := &file_proto_provider_plugin_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -285,7 +379,7 @@ func (x *NewAuthURLReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use NewAuthURLReq.ProtoReflect.Descriptor instead.
func (*NewAuthURLReq) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{4}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{6}
}
func (x *NewAuthURLReq) GetState() string {
@ -306,7 +400,7 @@ type NewAuthURLResp struct {
func (x *NewAuthURLResp) Reset() {
*x = NewAuthURLResp{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[5]
mi := &file_proto_provider_plugin_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -319,7 +413,7 @@ func (x *NewAuthURLResp) String() string {
func (*NewAuthURLResp) ProtoMessage() {}
func (x *NewAuthURLResp) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[5]
mi := &file_proto_provider_plugin_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -332,7 +426,7 @@ func (x *NewAuthURLResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use NewAuthURLResp.ProtoReflect.Descriptor instead.
func (*NewAuthURLResp) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{5}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{7}
}
func (x *NewAuthURLResp) GetUrl() string {
@ -353,7 +447,7 @@ type GetUserInfoReq struct {
func (x *GetUserInfoReq) Reset() {
*x = GetUserInfoReq{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[6]
mi := &file_proto_provider_plugin_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -366,7 +460,7 @@ func (x *GetUserInfoReq) String() string {
func (*GetUserInfoReq) ProtoMessage() {}
func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[6]
mi := &file_proto_provider_plugin_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -379,7 +473,7 @@ func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserInfoReq.ProtoReflect.Descriptor instead.
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{6}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{8}
}
func (x *GetUserInfoReq) GetToken() *Token {
@ -396,13 +490,12 @@ type GetUserInfoResp struct {
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
ProviderUserId uint64 `protobuf:"varint,2,opt,name=provider_user_id,json=providerUserId,proto3" json:"provider_user_id,omitempty"`
TokenRefreshed *Token `protobuf:"bytes,3,opt,name=token_refreshed,json=tokenRefreshed,proto3" json:"token_refreshed,omitempty"`
}
func (x *GetUserInfoResp) Reset() {
*x = GetUserInfoResp{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[7]
mi := &file_proto_provider_plugin_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -415,7 +508,7 @@ func (x *GetUserInfoResp) String() string {
func (*GetUserInfoResp) ProtoMessage() {}
func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[7]
mi := &file_proto_provider_plugin_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -428,7 +521,7 @@ func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserInfoResp.ProtoReflect.Descriptor instead.
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{7}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{9}
}
func (x *GetUserInfoResp) GetUsername() string {
@ -445,13 +538,6 @@ func (x *GetUserInfoResp) GetProviderUserId() uint64 {
return 0
}
func (x *GetUserInfoResp) GetTokenRefreshed() *Token {
if x != nil {
return x.TokenRefreshed
}
return nil
}
type Enpty struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -461,7 +547,7 @@ type Enpty struct {
func (x *Enpty) Reset() {
*x = Enpty{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_provider_plugin_proto_msgTypes[8]
mi := &file_proto_provider_plugin_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -474,7 +560,7 @@ func (x *Enpty) String() string {
func (*Enpty) ProtoMessage() {}
func (x *Enpty) ProtoReflect() protoreflect.Message {
mi := &file_proto_provider_plugin_proto_msgTypes[8]
mi := &file_proto_provider_plugin_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -487,7 +573,7 @@ func (x *Enpty) ProtoReflect() protoreflect.Message {
// Deprecated: Use Enpty.ProtoReflect.Descriptor instead.
func (*Enpty) Descriptor() ([]byte, []int) {
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{8}
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{10}
}
var File_proto_provider_plugin_proto protoreflect.FileDescriptor
@ -513,6 +599,13 @@ var file_proto_provider_plugin_proto_rawDesc = []byte{
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72,
0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69,
0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79,
0x22, 0x36, 0x0a, 0x0f, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
0x52, 0x65, 0x71, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74,
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72,
0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x36, 0x0a, 0x10, 0x52, 0x65, 0x66, 0x72,
0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x05,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x22, 0x22, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x0d, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55,
@ -523,35 +616,36 @@ var file_proto_provider_plugin_proto_rawDesc = []byte{
0x34, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
0x71, 0x12, 0x22, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,
0x72, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
0x0e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12,
0x35, 0x0a, 0x0f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68,
0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66,
0x72, 0x65, 0x73, 0x68, 0x65, 0x64, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x32,
0x94, 0x02, 0x0a, 0x0c, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x32, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x12, 0x26, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x76,
0x69, 0x64, 0x65, 0x72, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x70,
0x74, 0x79, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69,
0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0a, 0x4e, 0x65, 0x77,
0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b,
0x65, 0x6e, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f,
0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54,
0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65,
0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x76,
0x69, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x57, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,
0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e,
0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x07,
0x0a, 0x05, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x32, 0xd7, 0x02, 0x0a, 0x0c, 0x4f, 0x61, 0x75, 0x74,
0x68, 0x32, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x26, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74,
0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71,
0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x22, 0x00,
0x12, 0x2f, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0c, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22,
0x00, 0x12, 0x3b, 0x0a, 0x0a, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x12,
0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55,
0x52, 0x4c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65,
0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2e,
0x0a, 0x08, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0c,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x41,
0x0a, 0x0c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f,
0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52,
0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22,
0x00, 0x12, 0x3e, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x22,
0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -566,36 +660,40 @@ func file_proto_provider_plugin_proto_rawDescGZIP() []byte {
return file_proto_provider_plugin_proto_rawDescData
}
var file_proto_provider_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_proto_provider_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_proto_provider_plugin_proto_goTypes = []interface{}{
(*InitReq)(nil), // 0: proto.InitReq
(*GetTokenReq)(nil), // 1: proto.GetTokenReq
(*Token)(nil), // 2: proto.Token
(*ProviderResp)(nil), // 3: proto.ProviderResp
(*NewAuthURLReq)(nil), // 4: proto.NewAuthURLReq
(*NewAuthURLResp)(nil), // 5: proto.NewAuthURLResp
(*GetUserInfoReq)(nil), // 6: proto.GetUserInfoReq
(*GetUserInfoResp)(nil), // 7: proto.GetUserInfoResp
(*Enpty)(nil), // 8: proto.Enpty
(*InitReq)(nil), // 0: proto.InitReq
(*GetTokenReq)(nil), // 1: proto.GetTokenReq
(*Token)(nil), // 2: proto.Token
(*RefreshTokenReq)(nil), // 3: proto.RefreshTokenReq
(*RefreshTokenResp)(nil), // 4: proto.RefreshTokenResp
(*ProviderResp)(nil), // 5: proto.ProviderResp
(*NewAuthURLReq)(nil), // 6: proto.NewAuthURLReq
(*NewAuthURLResp)(nil), // 7: proto.NewAuthURLResp
(*GetUserInfoReq)(nil), // 8: proto.GetUserInfoReq
(*GetUserInfoResp)(nil), // 9: proto.GetUserInfoResp
(*Enpty)(nil), // 10: proto.Enpty
}
var file_proto_provider_plugin_proto_depIdxs = []int32{
2, // 0: proto.GetUserInfoReq.token:type_name -> proto.Token
2, // 1: proto.GetUserInfoResp.token_refreshed:type_name -> proto.Token
0, // 2: proto.Oauth2Plugin.Init:input_type -> proto.InitReq
8, // 3: proto.Oauth2Plugin.Provider:input_type -> proto.Enpty
4, // 4: proto.Oauth2Plugin.NewAuthURL:input_type -> proto.NewAuthURLReq
1, // 5: proto.Oauth2Plugin.GetToken:input_type -> proto.GetTokenReq
6, // 6: proto.Oauth2Plugin.GetUserInfo:input_type -> proto.GetUserInfoReq
8, // 7: proto.Oauth2Plugin.Init:output_type -> proto.Enpty
3, // 8: proto.Oauth2Plugin.Provider:output_type -> proto.ProviderResp
5, // 9: proto.Oauth2Plugin.NewAuthURL:output_type -> proto.NewAuthURLResp
2, // 10: proto.Oauth2Plugin.GetToken:output_type -> proto.Token
7, // 11: proto.Oauth2Plugin.GetUserInfo:output_type -> proto.GetUserInfoResp
7, // [7:12] is the sub-list for method output_type
2, // [2:7] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
2, // 0: proto.RefreshTokenResp.token:type_name -> proto.Token
2, // 1: proto.GetUserInfoReq.token:type_name -> proto.Token
0, // 2: proto.Oauth2Plugin.Init:input_type -> proto.InitReq
10, // 3: proto.Oauth2Plugin.Provider:input_type -> proto.Enpty
6, // 4: proto.Oauth2Plugin.NewAuthURL:input_type -> proto.NewAuthURLReq
1, // 5: proto.Oauth2Plugin.GetToken:input_type -> proto.GetTokenReq
3, // 6: proto.Oauth2Plugin.RefreshToken:input_type -> proto.RefreshTokenReq
8, // 7: proto.Oauth2Plugin.GetUserInfo:input_type -> proto.GetUserInfoReq
10, // 8: proto.Oauth2Plugin.Init:output_type -> proto.Enpty
5, // 9: proto.Oauth2Plugin.Provider:output_type -> proto.ProviderResp
7, // 10: proto.Oauth2Plugin.NewAuthURL:output_type -> proto.NewAuthURLResp
2, // 11: proto.Oauth2Plugin.GetToken:output_type -> proto.Token
4, // 12: proto.Oauth2Plugin.RefreshToken:output_type -> proto.RefreshTokenResp
9, // 13: proto.Oauth2Plugin.GetUserInfo:output_type -> proto.GetUserInfoResp
8, // [8:14] is the sub-list for method output_type
2, // [2:8] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_proto_provider_plugin_proto_init() }
@ -641,7 +739,7 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ProviderResp); i {
switch v := v.(*RefreshTokenReq); i {
case 0:
return &v.state
case 1:
@ -653,7 +751,7 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NewAuthURLReq); i {
switch v := v.(*RefreshTokenResp); i {
case 0:
return &v.state
case 1:
@ -665,7 +763,7 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NewAuthURLResp); i {
switch v := v.(*ProviderResp); i {
case 0:
return &v.state
case 1:
@ -677,7 +775,7 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoReq); i {
switch v := v.(*NewAuthURLReq); i {
case 0:
return &v.state
case 1:
@ -689,7 +787,7 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoResp); i {
switch v := v.(*NewAuthURLResp); i {
case 0:
return &v.state
case 1:
@ -701,6 +799,30 @@ func file_proto_provider_plugin_proto_init() {
}
}
file_proto_provider_plugin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_provider_plugin_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_provider_plugin_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Enpty); i {
case 0:
return &v.state
@ -719,7 +841,7 @@ func file_proto_provider_plugin_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_provider_plugin_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},

@ -18,6 +18,10 @@ message Token {
int64 expiry = 4;
}
message RefreshTokenReq { string refresh_token = 1; }
message RefreshTokenResp { Token token = 1; }
message ProviderResp { string name = 1; }
message NewAuthURLReq { string state = 1; }
@ -29,7 +33,6 @@ message GetUserInfoReq { Token token = 1; }
message GetUserInfoResp {
string username = 1;
uint64 provider_user_id = 2;
Token token_refreshed = 3;
}
message Enpty {}
@ -39,5 +42,6 @@ service Oauth2Plugin {
rpc Provider(Enpty) returns (ProviderResp) {}
rpc NewAuthURL(NewAuthURLReq) returns (NewAuthURLResp) {}
rpc GetToken(GetTokenReq) returns (Token) {}
rpc RefreshToken(RefreshTokenReq) returns (RefreshTokenResp) {}
rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoResp) {}
}

@ -19,11 +19,12 @@ import (
const _ = grpc.SupportPackageIsVersion7
const (
Oauth2Plugin_Init_FullMethodName = "/proto.Oauth2Plugin/Init"
Oauth2Plugin_Provider_FullMethodName = "/proto.Oauth2Plugin/Provider"
Oauth2Plugin_NewAuthURL_FullMethodName = "/proto.Oauth2Plugin/NewAuthURL"
Oauth2Plugin_GetToken_FullMethodName = "/proto.Oauth2Plugin/GetToken"
Oauth2Plugin_GetUserInfo_FullMethodName = "/proto.Oauth2Plugin/GetUserInfo"
Oauth2Plugin_Init_FullMethodName = "/proto.Oauth2Plugin/Init"
Oauth2Plugin_Provider_FullMethodName = "/proto.Oauth2Plugin/Provider"
Oauth2Plugin_NewAuthURL_FullMethodName = "/proto.Oauth2Plugin/NewAuthURL"
Oauth2Plugin_GetToken_FullMethodName = "/proto.Oauth2Plugin/GetToken"
Oauth2Plugin_RefreshToken_FullMethodName = "/proto.Oauth2Plugin/RefreshToken"
Oauth2Plugin_GetUserInfo_FullMethodName = "/proto.Oauth2Plugin/GetUserInfo"
)
// Oauth2PluginClient is the client API for Oauth2Plugin service.
@ -34,6 +35,7 @@ type Oauth2PluginClient interface {
Provider(ctx context.Context, in *Enpty, opts ...grpc.CallOption) (*ProviderResp, error)
NewAuthURL(ctx context.Context, in *NewAuthURLReq, opts ...grpc.CallOption) (*NewAuthURLResp, error)
GetToken(ctx context.Context, in *GetTokenReq, opts ...grpc.CallOption) (*Token, error)
RefreshToken(ctx context.Context, in *RefreshTokenReq, opts ...grpc.CallOption) (*RefreshTokenResp, error)
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
}
@ -81,6 +83,15 @@ func (c *oauth2PluginClient) GetToken(ctx context.Context, in *GetTokenReq, opts
return out, nil
}
func (c *oauth2PluginClient) RefreshToken(ctx context.Context, in *RefreshTokenReq, opts ...grpc.CallOption) (*RefreshTokenResp, error) {
out := new(RefreshTokenResp)
err := c.cc.Invoke(ctx, Oauth2Plugin_RefreshToken_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *oauth2PluginClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
out := new(GetUserInfoResp)
err := c.cc.Invoke(ctx, Oauth2Plugin_GetUserInfo_FullMethodName, in, out, opts...)
@ -98,6 +109,7 @@ type Oauth2PluginServer interface {
Provider(context.Context, *Enpty) (*ProviderResp, error)
NewAuthURL(context.Context, *NewAuthURLReq) (*NewAuthURLResp, error)
GetToken(context.Context, *GetTokenReq) (*Token, error)
RefreshToken(context.Context, *RefreshTokenReq) (*RefreshTokenResp, error)
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
mustEmbedUnimplementedOauth2PluginServer()
}
@ -118,6 +130,9 @@ func (UnimplementedOauth2PluginServer) NewAuthURL(context.Context, *NewAuthURLRe
func (UnimplementedOauth2PluginServer) GetToken(context.Context, *GetTokenReq) (*Token, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetToken not implemented")
}
func (UnimplementedOauth2PluginServer) RefreshToken(context.Context, *RefreshTokenReq) (*RefreshTokenResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented")
}
func (UnimplementedOauth2PluginServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented")
}
@ -206,6 +221,24 @@ func _Oauth2Plugin_GetToken_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler)
}
func _Oauth2Plugin_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RefreshTokenReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(Oauth2PluginServer).RefreshToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Oauth2Plugin_RefreshToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(Oauth2PluginServer).RefreshToken(ctx, req.(*RefreshTokenReq))
}
return interceptor(ctx, in, info, handler)
}
func _Oauth2Plugin_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserInfoReq)
if err := dec(in); err != nil {
@ -247,6 +280,10 @@ var Oauth2Plugin_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetToken",
Handler: _Oauth2Plugin_GetToken_Handler,
},
{
MethodName: "RefreshToken",
Handler: _Oauth2Plugin_RefreshToken_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _Oauth2Plugin_GetUserInfo_Handler,

Loading…
Cancel
Save