login

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ACCEPT             = "application/json, text/plain, */*"
	DEFAULT_ACCEPT_LANGUAGE    = "en-US,en;q=0.5"
	DEFAULT_LOGIN_URL          = "https://www.vodafone.de/mint/rest/v60/session/start"
	DEFAULT_TARGET_URL         = ""
	DEFAULT_USER_AGENT         = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0"
	DEFAULT_REFERER            = "https://www.vodafone.de/meinvodafone/account/login"
	OIDC_AUTHORIZE_URL         = "https://www.vodafone.de/mint/oidc/authorize"
	OIDC_RESPONSE_TYPE         = "code"
	OIDC_CLIENT_ID             = "b0595a44-0726-11ec-9011-9457a55a403c"
	OIDC_SCOPES                = "openid profile webseal user-groups user-accounts validate-token update-email-username account"
	OIDC_REDIRECT_URI          = "https://www.vodafone.de/meinvodafone/services/"
	OIDC_CODE_CHALLENGE_METHOD = "S256"
	OIDC_PROMPT                = "none"
	OIDC_CODE_CHALLENGE_LENGTH = 43
	OIDC_TOKEN_URL             = "https://www.vodafone.de/mint/oidc/token"
	OIDC_GRANT_TYPE            = "authorization_code"
	// Hard coded API key in the website of vodafone. This is not a secret. It is used to authenticate the API.
	// It is highly likely that this can change and needs to be updated after some time.
	DEFAULT_API_KEY = "aEIoMCae0A933wBL0bLlS6SwSBfkKwM5"
)
View Source
const USER_INFO_URL = "https://api.vodafone.de/meinvodafone/v2/user/userInfo"

Variables

View Source
var (
	ErrLoginFailed = errors.New("Login failed")
)
View Source
var (
	ErrUserInfoRequestFailed = errors.New("user info request failed")
)

Functions

This section is empty.

Types

type ActiveContractCable

type ActiveContractCable struct {
	ID   int    `json:"id"` // It is the same as `ID` in `CableSubscription` but as an integer because Vodafone is inconsistent
	Name string `json:"name"`
}

func (*ActiveContractCable) IDString

func (activeContractCable *ActiveContractCable) IDString() string

type CableAccount

type CableAccount struct {
	ID                string               `json:"id"`
	Name              string               `json:"name"`
	IsActiveContract  bool                 `json:"isActiveContract"`
	IsDefaultContract bool                 `json:"isDefaultContract"`
	HasCableMail      bool                 `json:"hasCableMail"`
	Subscriptions     []*CableSubscription `json:"subscription"`
}

type CableSubscription

type CableSubscription struct {
	ID            string `json:"id"`
	ActivatedDate string `json:"activatedDate"`
	Type          string `json:"type"`
	DisplayName   string `json:"displayName"`
}

type LoginData

type LoginData struct {
	Cookies      []*http.Cookie
	OIDCResponse *OIDCResponse
}

func Do

func Do(user string, credential string) (*LoginData, error)

func FromEnvironmentVariables

func FromEnvironmentVariables() (*LoginData, error)

func (*LoginData) AuthenticateAPI

func (loginData *LoginData) AuthenticateAPI(request *http.Request) *http.Request

func (*LoginData) GetToken

func (loginData *LoginData) GetToken() string

type OIDCResponse

type OIDCResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
	IDToken     string `json:"id_token"`
}

type OnlineUser

type OnlineUser struct {
	MintUserID            int    `json:"mintUserId"`
	UserName              string `json:"userName"`
	Title                 string `json:"title"`
	FirstName             string `json:"firstName"`
	LastName              string `json:"lastName"`
	LastLoginDate         string `json:"lastLoginDate"`
	PrimaryEmail          string `json:"primaryEmail"`
	EmailValidationStatus string `json:"emailValidationStatus"`
	IsFirstLogin          bool   `json:"isFirstLogin"`
	PermissionFlag        bool   `json:"permissionFlag"`
}

func (*OnlineUser) HumanReadableString

func (onlineUser *OnlineUser) HumanReadableString() string

type UserAccountVBO

type UserAccountVBO struct {
	AuthLevel           string               `json:"authLevel"`
	OnlineUser          *OnlineUser          `json:"onlineUser,omitempty"`
	CableAccounts       []*CableAccount      `json:"cable,omitempty"`
	ActiveContractCable *ActiveContractCable `json:"activeContractCable,omitempty"`
}

func (*UserAccountVBO) GetActiveContractCableID

func (userAccountVBO *UserAccountVBO) GetActiveContractCableID() string

func (*UserAccountVBO) GetAllContractIDs

func (userAccountVBO *UserAccountVBO) GetAllContractIDs() []string

func (*UserAccountVBO) HumanReadableContractTable

func (UserAccountVBO *UserAccountVBO) HumanReadableContractTable() string

func (*UserAccountVBO) HumanReadableString

func (userAccountVBO *UserAccountVBO) HumanReadableString() string

type UserInfo

type UserInfo struct {
	UserAccountVBO *UserAccountVBO `json:"userAccountVBO"`
}

func GetUserInfo

func GetUserInfo(bearerToken fetcher.BearerToken) (*UserInfo, error)

func (*UserInfo) GetActiveContractCableID

func (userInfo *UserInfo) GetActiveContractCableID() string

func (*UserInfo) GetAllContractIDs

func (userInfo *UserInfo) GetAllContractIDs() []string

func (*UserInfo) HumanReadableString

func (userInfo *UserInfo) HumanReadableString() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL