func (s *OAuthScheme) Auth(header string) (auth.Token, error) { token, err := getToken(header) if err != nil { nativeScheme := native.NativeScheme{} token, nativeErr := nativeScheme.Auth(header) if nativeErr == nil && token.IsAppToken() { return token, nil } return nil, err } config, err := s.loadConfig() if err != nil { return nil, err } client := config.Client(context.Background(), &token.Token) rsp, err := client.Get(s.InfoUrl) if err != nil { return nil, err } defer rsp.Body.Close() return token, nil }
func (s *OAuthScheme) Auth(header string) (auth.Token, error) { token, err := getToken(header) if err != nil { nativeScheme := native.NativeScheme{} token, nativeErr := nativeScheme.Auth(header) if nativeErr == nil && token.IsAppToken() { return token, nil } return nil, err } config, err := s.loadConfig() if err != nil { return nil, err } transport := goauth2.Transport{Config: &config} transport.Token = &token.Token client := transport.Client() _, err = client.Get(s.InfoUrl) if err != nil { return nil, err } return makeToken(transport.Token), nil }