// Authorize the session with Twitter and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier")) if err != nil { return "", err } s.AccessToken = accessToken return accessToken.Token, err }
// Authorize the session with Linkedin and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) token, err := p.config.Exchange(oauth2.NoContext, params.Get("code")) if err != nil { return "", err } s.AccessToken = token.AccessToken return token.AccessToken, err }
// Authorize the session with LastFM and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) sess, err := p.GetSession(params.Get("token")) if err != nil { return "", err } s.AccessToken = sess["token"] s.Login = sess["login"] return sess["token"], err }
// Authorize the session with Facebook and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) token, err := p.config.Exchange(oauth2.NoContext, params.Get("code")) if err != nil { return "", err } if "" == token.AccessToken { return "", errors.New("Not Authorized") } //println("Slack.Authorize accessToken:", token.AccessToken) s.AccessToken = token.AccessToken s.RefreshToken = token.RefreshToken return token.AccessToken, err }
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) data := url.Values{} data.Add("code", params.Get("code")) data.Add("grant_type", "authorization_code") data.Add("client_id", p.config.ClientID) data.Add("client_secret", p.config.ClientSecret) data.Add("redirect_uri", p.config.RedirectURL) res, err := http.PostForm(p.config.Endpoint.TokenURL, data) if err != nil { return "", err } defer res.Body.Close() token := &oauth2.Token{} err = json.NewDecoder(res.Body).Decode(token) if err != nil { return "", err } s.AccessToken = token.AccessToken s.RefreshToken = token.RefreshToken return token.AccessToken, nil }