145 lines
3.1 KiB
Protocol Buffer
145 lines
3.1 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package lab.weixin.mp.auth;
|
|
|
|
option go_package = "git.esin.io/lab/weixin/protobuf/mp/auth;authpb";
|
|
|
|
import "google/api/annotations.proto";
|
|
import "google/protobuf/timestamp.proto";
|
|
import "google/protobuf/empty.proto";
|
|
|
|
service AuthService {
|
|
rpc GetCodeURL(GetCodeURLRequest) returns (GetCodeURLResponse) {
|
|
option (google.api.http) = {
|
|
get: "/weixin/mp/auth/url"
|
|
};
|
|
}
|
|
|
|
rpc ExchangeToken(ExchangeTokenRequest) returns (ExchangeTokenResponse) {
|
|
option (google.api.http) = {
|
|
get: "/weixin/mp/auth/token"
|
|
};
|
|
}
|
|
|
|
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {
|
|
option (google.api.http) = {
|
|
post: "/weixin/mp/auth/token"
|
|
body: "*"
|
|
};
|
|
}
|
|
|
|
rpc GetUserinfo(GetUserinfoRequest) returns (GetUserinfoResponse) {
|
|
option (google.api.http) = {
|
|
get: "/weixin/mp/auth/userinfo"
|
|
};
|
|
}
|
|
|
|
// synchronize userinfo when its updated
|
|
rpc SyncUserinfo(SyncUserinfoRequest) returns (SyncUserinfoResponse) {
|
|
option (google.api.http) = {
|
|
get: "/weixin/mp/auth/userinfo/sync"
|
|
};
|
|
}
|
|
|
|
rpc GetClientCredential(google.protobuf.Empty) returns (GetClientCredentialResponse) {
|
|
option (google.api.http) = {
|
|
get: "/weixin/mp/auth/clientcredential"
|
|
};
|
|
}
|
|
}
|
|
|
|
message GetCodeURLRequest {
|
|
string redirect_url = 1;
|
|
string state = 2;
|
|
enum Scope {
|
|
snsapi_base = 0;
|
|
snsapi_userinfo = 1;
|
|
}
|
|
Scope scope = 3;
|
|
}
|
|
|
|
message GetCodeURLResponse {
|
|
string url = 1;
|
|
}
|
|
|
|
message ExchangeTokenRequest {
|
|
string code = 1;
|
|
}
|
|
|
|
message Token {
|
|
string access_token = 1;
|
|
int32 expires_in = 2;
|
|
string refresh_token = 3;
|
|
string open_id = 4;
|
|
string scope = 5;
|
|
}
|
|
|
|
message ExchangeTokenResponse {
|
|
Token token = 1;
|
|
google.protobuf.Timestamp timestamp = 2;
|
|
}
|
|
|
|
message RefreshTokenRequest {
|
|
string open_id = 1;
|
|
}
|
|
|
|
message RefreshTokenResponse {
|
|
Token token = 1;
|
|
google.protobuf.Timestamp timestamp = 2;
|
|
}
|
|
|
|
message Userinfo {
|
|
string open_id = 1;
|
|
string nick_name = 2;
|
|
int32 sex = 3;
|
|
string province = 4;
|
|
string city = 5;
|
|
string country = 6;
|
|
string head_img_url = 7;
|
|
repeated string privilege = 8;
|
|
string union_id = 9;
|
|
}
|
|
|
|
message GetUserinfoRequest {
|
|
string open_id = 1;
|
|
enum Lang {
|
|
zh_CN = 0;
|
|
zh_TW = 1;
|
|
en = 2;
|
|
}
|
|
Lang lang = 2;
|
|
}
|
|
|
|
message GetUserinfoResponse {
|
|
Userinfo userinfo = 1;
|
|
google.protobuf.Timestamp created_time = 2;
|
|
google.protobuf.Timestamp updated_time = 3;
|
|
}
|
|
|
|
message SyncUserinfoRequest {
|
|
string open_id = 1;
|
|
enum Lang {
|
|
zh_CN = 0;
|
|
zh_TW = 1;
|
|
en = 2;
|
|
}
|
|
Lang lang = 2;
|
|
}
|
|
|
|
message SyncUserinfoResponse {
|
|
Userinfo userinfo = 1;
|
|
google.protobuf.Timestamp created_time = 2;
|
|
google.protobuf.Timestamp updated_time = 3;
|
|
}
|
|
|
|
message ClientCredential {
|
|
string access_token = 1;
|
|
int32 expires_in = 2;
|
|
}
|
|
|
|
message GetClientCredentialResponse {
|
|
ClientCredential client_credential = 1;
|
|
google.protobuf.Timestamp timestamp = 2;
|
|
}
|
|
|