Documentation ¶
Index ¶
- Constants
- func GetEvernoteAccessToken(evernoteHost string, requestToken string, requestSecret string, ...) (string, string, map[string]string, error)
- func GetEvernoteTempRequestToken(evernoteHost string, redirectUri string, isSandbox bool) (string, string, string, *oauth.Consumer, error)
- func GetOauthConsumer(reqTokenUri string, authTokenUri string, accessTokenUri string, debugMode bool) *oauth.Consumer
- type AuthStageResult
- type BotError
- type EvernoteAuthBot
- func (bot *EvernoteAuthBot) AllowAccess(tmpOauthToken string, results chan<- AuthStageResult)
- func (bot *EvernoteAuthBot) ApiCredentials() (string, string, error)
- func (bot *EvernoteAuthBot) Cookie(name string) *http.Cookie
- func (bot *EvernoteAuthBot) GetOauthToken(tmpOauthToken string, verifier string, results chan<- AuthStageResult)
- func (bot *EvernoteAuthBot) GetTmpOauthToken(results chan<- AuthStageResult)
- func (bot *EvernoteAuthBot) HandleTwoFactor(authCode string, results chan<- AuthStageResult)
- func (bot *EvernoteAuthBot) LoadPage(uri string, method string, params url.Values) (*http.Response, error)
- func (bot *EvernoteAuthBot) Login(username string, password string, results chan<- AuthStageResult)
- func (bot *EvernoteAuthBot) PostData() map[string]url.Values
- func (bot *EvernoteAuthBot) TempOauthToken() string
Constants ¶
const ( ENV_EVERNOTE_HOST = "EVERNOTE_HOST" ENV_CONSUMER_KEY = "EVERNOTE_API_KEY" ENV_CONSUMER_SECRET = "EVERNOTE_API_SECRET" ENV_CALLBACK_URL = "EVERNOTE_SERVICE_CALLBACK" ENV_EVERNOTE_DEBUG = "EVERNOTE_DEBUG" )
Environment variables for configuration
const ( REQUEST_TOKEN_URL = "/oauth" AUTHORIZE_TOKEN_URL = "/OAuth.action" ACCESS_TOKEN_URL = "/oauth" )
const ( ENV_API_KEY = "EVERNOTE_API_KEY" ENV_API_SECRET = "EVERNOTE_API_SECRET" ENV_IS_SANDBOX = "EVERNOTE_IS_SANDBOX" )
CONSTANTS
Variables ¶
This section is empty.
Functions ¶
func GetEvernoteAccessToken ¶
func GetEvernoteAccessToken(evernoteHost string, requestToken string, requestSecret string, verifier string, isSandbox bool) (string, string, map[string]string, error)
GetEvernoteAccessToken returns the access token, the secret and any additional data. We basically decompose the oauth.AccessToken struct that is returned.
Types ¶
type AuthStageResult ¶
type AuthStageResult struct { // In case of error Error error // http.Request objects will commonly be assigned to this. ErrorAssocObject interface{} // the results are stored here. Per method basis Elements map[string]interface{} }
AuthStageResult contains the result for a particular stage in the authentication process.
type EvernoteAuthBot ¶
type EvernoteAuthBot struct {
// contains filtered or unexported fields
}
EvernoteAuthBot will do the authentication via HTTP requests, storing state as it does so. Basically, it does the required HTTP requests as if you were logging into Evernote on the web.
func (*EvernoteAuthBot) AllowAccess ¶
func (bot *EvernoteAuthBot) AllowAccess(tmpOauthToken string, results chan<- AuthStageResult)
func (*EvernoteAuthBot) ApiCredentials ¶
func (bot *EvernoteAuthBot) ApiCredentials() (string, string, error)
ApiCredentials will get the API key and secret from environment variables. This library relies on environment variables to pull out
func (*EvernoteAuthBot) Cookie ¶
func (bot *EvernoteAuthBot) Cookie(name string) *http.Cookie
Cookie returns a *http.Cookie that has a Name matching the name argument which was set in the process of authentication.
func (*EvernoteAuthBot) GetOauthToken ¶
func (bot *EvernoteAuthBot) GetOauthToken( tmpOauthToken string, verifier string, results chan<- AuthStageResult, )
func (*EvernoteAuthBot) GetTmpOauthToken ¶
func (bot *EvernoteAuthBot) GetTmpOauthToken(results chan<- AuthStageResult)
GetTmpOauthToken will query for the initial temporary oauth token that evernote requests for the authentication process to proceed.
func (*EvernoteAuthBot) HandleTwoFactor ¶
func (bot *EvernoteAuthBot) HandleTwoFactor(authCode string, results chan<- AuthStageResult)
HandleTwoFactor will ask user for 2FA code before proceeding to request for access
func (*EvernoteAuthBot) LoadPage ¶
func (bot *EvernoteAuthBot) LoadPage(uri string, method string, params url.Values) (*http.Response, error)
LoadPage sends HTTP requests and does some minimal parsing of the response. At this point this means we extract the cookies. Only handles GET and POST requests as of now.
func (*EvernoteAuthBot) Login ¶
func (bot *EvernoteAuthBot) Login( username string, password string, results chan<- AuthStageResult, )
Login prompts user for credentials (including 2FA). Exits if invalid credentials provided.
func (*EvernoteAuthBot) TempOauthToken ¶
func (bot *EvernoteAuthBot) TempOauthToken() string