@@ -26,17 +26,28 @@ type Provider struct {
2626 HTTPClient * http.Client
2727 config * oauth2.Config
2828 providerName string
29+ AuthURL string
30+ TokenURL string
31+ ProfileURL string
2932}
3033
3134// New creates a new Feishu provider, and sets up important connection details.
3235// You should always call `feishu.New` to get a new Provider. Never try to create
3336// one manually.
3437func New (clientKey , secret , callbackURL string , scopes ... string ) * Provider {
38+ return NewCustomisedURL (clientKey , secret , callbackURL , AuthURL , TokenURL , ProfileURL , scopes ... )
39+ }
40+
41+ // NewCustomisedURL is similar to New(...) but can be used to set custom URLs to connect to
42+ func NewCustomisedURL (clientKey , secret , callbackURL , AuthURL , TokenURL , ProfileURL string , scopes ... string ) * Provider {
3543 p := & Provider {
3644 ClientKey : clientKey ,
3745 Secret : secret ,
3846 CallbackURL : callbackURL ,
3947 providerName : "feishu" ,
48+ AuthURL : AuthURL ,
49+ TokenURL : TokenURL ,
50+ ProfileURL : ProfileURL ,
4051 }
4152 p .config = newConfig (p , scopes )
4253 return p
@@ -48,8 +59,8 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
4859 ClientSecret : provider .Secret ,
4960 RedirectURL : provider .CallbackURL ,
5061 Endpoint : oauth2.Endpoint {
51- AuthURL : AuthURL ,
52- TokenURL : TokenURL ,
62+ AuthURL : provider . AuthURL ,
63+ TokenURL : provider . TokenURL ,
5364 },
5465 Scopes : []string {},
5566 }
@@ -138,7 +149,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
138149 }
139150
140151 // Get user information
141- reqProfile , err := http .NewRequest ("GET" , ProfileURL , nil )
152+ reqProfile , err := http .NewRequest ("GET" , p . ProfileURL , nil )
142153 if err != nil {
143154 return user , err
144155 }
0 commit comments