Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Интерфейс для авторизации #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tdakkota
Copy link
Contributor

#78
#70

для пула можно использовать такую реализацию

func TokenPoolAuthenticator(tokens ...string) Authenticator {
        tokenPool := internal.NewTokenPool(tokens...)
	return AuthenticatorFunc(func(params Params) error {
		if _, ok := params["access_token"]; !ok {
			params["access_token"] = tokenPool.Get()
		}

		return nil
	})
}

api/authenticator.go Show resolved Hide resolved
api/authenticator.go Show resolved Hide resolved
api/authenticator.go Show resolved Hide resolved
api/authenticator.go Outdated Show resolved Hide resolved
api/authenticator.go Show resolved Hide resolved
api/authenticator.go Outdated Show resolved Hide resolved
api/authenticator.go Show resolved Hide resolved
api/authenticator.go Outdated Show resolved Hide resolved
return
}

resp, err := http.Post(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response body must be closed (from bodyclose)


// Authenticator interface
type Authenticator interface {
Authenticate(params Params) error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможно, стоит использовать req *http.Request вместо params Params
Тогда, например, можно будет установить конкретные куки(получение токена с Desktop в vk_api)

@SevereCloud SevereCloud added the enhancement New feature or request label Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants