Last active
October 26, 2017 01:09
-
-
Save kanapuli/64d681d264a6336378e9641d1839f123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SlackSignIn gives the Authentication token in return to the code | |
func (LoginService) SlackSignIn(ctx context.Context, code string) (token SlackTokenResponse, err error) { | |
conf := &oauth2.Config{ | |
ClientID: slackClientID, | |
ClientSecret: slackClientSecret, | |
Scopes: slackScopes, | |
Endpoint: oauth2.Endpoint{ | |
AuthURL: slackAuthURL, | |
TokenURL: slackTokenURL, | |
}, | |
} | |
httpClient := &http.Client{Timeout: 2 * time.Second} | |
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient) | |
tok, err := conf.Exchange(ctx, code) | |
if err != nil { | |
log.Fatal(err) | |
} | |
token = SlackTokenResponse{ | |
AccessToken: tok.AccessToken, | |
Expiry: tok.Expiry, | |
RefreshToken: tok.RefreshToken, | |
TokenType: tok.TokenType, | |
} | |
client := conf.Client(ctx, tok) | |
_ = client | |
return token, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment