...

Source file src/github.com/palantir/go-githubapp/oauth2/github.go

Documentation: github.com/palantir/go-githubapp/oauth2

     1  // Copyright 2018 Palantir Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package oauth2
    16  
    17  import (
    18  	"strings"
    19  
    20  	"github.com/palantir/go-githubapp/githubapp"
    21  	"golang.org/x/oauth2"
    22  )
    23  
    24  const (
    25  	DefaultRoute = "/api/github/auth"
    26  )
    27  
    28  func GetConfig(c githubapp.Config, scopes []string) *oauth2.Config {
    29  	return &oauth2.Config{
    30  		ClientID:     c.OAuth.ClientID,
    31  		ClientSecret: c.OAuth.ClientSecret,
    32  		Endpoint: oauth2.Endpoint{
    33  			AuthURL:  joinURL(c.WebURL, "/login/oauth/authorize"),
    34  			TokenURL: joinURL(c.WebURL, "/login/oauth/access_token"),
    35  		},
    36  		Scopes: scopes,
    37  	}
    38  }
    39  
    40  func joinURL(base, path string) string {
    41  	return strings.TrimSuffix(base, "/") + path
    42  }
    43  

View as plain text