Documentation ¶
Overview ¶
Package oauth ...
Package oauth ...
Package oauth ...
Package oauth ...
Index ¶
- Constants
- Variables
- func CheckScope(scope int, permissions ...int) bool
- func ImplicitFlowGroup(p GroupParams) *url.URL
- func ImplicitFlowUser(p UserParams) *url.URL
- type AuthCodeFlowGroup
- type AuthCodeFlowUser
- type DirectAuthParams
- type Display
- type Error
- type ErrorReason
- type ErrorType
- type GroupParams
- type GroupToken
- type GroupTokens
- type UserParams
- type UserToken
- type ValidationType
Constants ¶
const ( ScopeUserNotify = 1 << 0 ScopeUserFriends = 1 << 1 ScopeUserPhotos = 1 << 2 ScopeUserAudio = 1 << 3 ScopeUserVideo = 1 << 4 ScopeUserStories = 1 << 6 ScopeUserPages = 1 << 7 ScopeUserMenu = 1 << 8 ScopeUserStatus = 1 << 10 ScopeUserNotes = 1 << 11 ScopeUserMessages = 1 << 12 ScopeUserWall = 1 << 13 ScopeUserAds = 1 << 15 ScopeUserOffline = 1 << 16 ScopeUserDocs = 1 << 17 ScopeUserGroups = 1 << 18 ScopeUserNotifications = 1 << 19 ScopeUserStats = 1 << 20 ScopeUserEmail = 1 << 22 ScopeUserAdsweb = 1 << 23 ScopeUserLeads = 1 << 24 ScopeUserGroupMessages = 1 << 25 ScopeUserExchange = 1 << 26 ScopeUserMarket = 1 << 27 ScopeUserPhone = 1 << 28 )
Access Permissions for User Token.
const ( ScopeGroupStories = 1 << 0 ScopeGroupPhotos = 1 << 2 ScopeGroupAppWidget = 1 << 6 ScopeGroupMessages = 1 << 12 ScopeGroupDocs = 1 << 17 ScopeGroupManage = 1 << 18 )
Access Permissions for Community Token.
Variables ¶
var ( OAuthHost = "oauth.vk.com" DefaultRedirectURI = "https://oauth.vk.com/blank.html" )
Functions ¶
func ImplicitFlowGroup ¶
func ImplicitFlowGroup(p GroupParams) *url.URL
ImplicitFlowGroup need to run methods directly from users devices. Access token received this way can not be used for server requests.
func ImplicitFlowUser ¶
func ImplicitFlowUser(p UserParams) *url.URL
ImplicitFlowUser need to run methods directly from users devices. Access token received this way can not be used for server requests.
Types ¶
type AuthCodeFlowGroup ¶
type AuthCodeFlowGroup struct { Client *http.Client UserAgent string // contains filtered or unexported fields }
AuthCodeFlowGroup need to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address.
https://vk.com/dev/authcode_flow_group
func NewAuthCodeFlowGroup ¶
func NewAuthCodeFlowGroup(p GroupParams, clientSecret string) *AuthCodeFlowGroup
NewAuthCodeFlowGroup returns a new AuthcodeFlowGroup.
func (AuthCodeFlowGroup) Token ¶
func (a AuthCodeFlowGroup) Token(u *url.URL) (*GroupTokens, error)
Token ...
type AuthCodeFlowUser ¶
type AuthCodeFlowUser struct { Client *http.Client UserAgent string // contains filtered or unexported fields }
AuthCodeFlowUser need to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of permissions that can be granted is limited for security reasons.
https://vk.com/dev/authcode_flow_user
func NewAuthCodeFlowUser ¶
func NewAuthCodeFlowUser(p UserParams, clientSecret string) *AuthCodeFlowUser
NewAuthCodeFlowUser returns a new AuthcodeFlowUser.
type DirectAuthParams ¶
type DirectAuthParams struct { ClientSecret string ClientID int Username, Password string Scope int V string TwoFactorSupported bool ForceSMS bool Code string CaptchaSID string CaptchaKey string TestRedirectURI bool Client *http.Client UserAgent string }
DirectAuthParams parameters.
type Error ¶
type Error struct { Type ErrorType `json:"error"` Reason ErrorReason `json:"error_reason,omitempty"` Description string `json:"error_description,omitempty"` // For auth direct CaptchaSID string `json:"captcha_sid,omitempty"` CaptchaImg string `json:"captcha_img,omitempty"` RedirectURI string `json:"redirect_uri,omitempty"` ValidationType ValidationType `json:"validation_type,omitempty"` PhoneMask string `json:"phone_mask,omitempty"` }
Error for oauth.
type ErrorReason ¶
type ErrorReason string
ErrorReason for oauth.
const (
ErrUserDenied ErrorReason = "user_denied"
)
ErrorReason types.
func (ErrorReason) Error ¶
func (e ErrorReason) Error() string
Error returns the message of a Error.
type ErrorType ¶
type ErrorType string
ErrorType for oauth.
const ( ErrInvalidRequest ErrorType = "invalid_request" ErrUnsupportedResponseType ErrorType = "unsupported_response_type" ErrInvalidScope ErrorType = "invalid_scope" ErrServerError ErrorType = "server_error" ErrAccessDenied ErrorType = "access_denied" ErrInvalidGrant ErrorType = "invalid_grant" ErrNeedValidation ErrorType = "need_validation" ErrNeedCaptcha ErrorType = "need_captcha" )
Error types.
type GroupParams ¶
type GroupParams struct { ClientID int // required RedirectURI string GroupIDs []int Display Display // Default mobile Scope int V string // Default version module State string }
GroupParams struct.
type GroupToken ¶
GroupToken struct with access token.
type GroupTokens ¶
type GroupTokens struct { Groups []GroupToken `json:"groups"` ExpiresIn int `json:"expires_in"` }
GroupTokens struct with access tokens.
func NewGroupTokensFromJSON ¶
func NewGroupTokensFromJSON(data []byte) (*GroupTokens, error)
NewGroupTokensFromJSON return group tokens.
func NewGroupTokensFromURL ¶
func NewGroupTokensFromURL(u *url.URL) (*GroupTokens, error)
NewGroupTokensFromURL return group tokens.
type UserParams ¶
type UserParams struct { ClientID int // required RedirectURI string Display Display // Default mobile Scope int V string // Default version module State string }
UserParams struct.
type UserToken ¶
type UserToken struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` UserID int `json:"user_id"` Email string `json:"email,omitempty"` State string `json:"state,omitempty"` }
UserToken ...
func DirectAuth ¶
func DirectAuth(p DirectAuthParams) (*UserToken, error)
DirectAuth type of authorization.
Please note! This type of authorization is available only after preliminary approval of VK administration.
To apply for access you need to contact our support service at https://vk.com/support and specify you application ID.
Currently, this functionality is available only for the following categories:
- Fully functional clients. At the time you apply for access your application shall be functional (using standard authorization); and you shall provide the download link in the request.
- Applications for platforms which do not support standard authorization. Provide a short description of application functionality in the request.
Trusted applications can get time-unlimited access_token to access API by passing user's login and password.
Note that application shall not store user's password. Issued access_token is not bound to user's IP address, that is why it is sufficient for using API in the future without repeating authorization procedure.
func NewUserTokenFromJSON ¶
NewUserTokenFromJSON ...
type ValidationType ¶
type ValidationType string
ValidationType ...
const ( ValidationSMS ValidationType = "2fa_sms" ValidationApp ValidationType = "2fa_app" )
Possible values.