Exemple #1
0
func authorize(api *go140.API) (err os.Error) {
	api.ConsumerKey = "24eNIyd8EskIpi32cYFEbg"
	api.ConsumerSecret = "heXe5AP9tT4jMgWHyF6y17NWJRkJeRX7S7I7W78VmCc"
	api.SignatureMethod = oauth.HMAC_SHA1

	api.RequestTokenURL = "https://api.twitter.com/oauth/request_token"
	api.OwnerAuthURL = "https://api.twitter.com/oauth/authorize"
	api.AccessTokenURL = "https://api.twitter.com/oauth/access_token"
	api.Callback = "oob"

	api.Root = "http://api.twitter.com"

	err = api.Load(home + "/.go140.oauth")
	if err != nil {
		err = api.GetRequestToken()
		Error(err)
		url, err := api.AuthorizationURL()
		Error(err)
		fmt.Printf("Please visit the following URL for authorization:\n%s\n", url)

		var verifier string
		fmt.Printf("PIN: ")
		fmt.Scanf("%s", &verifier)
		err = api.GetAccessToken(verifier)
		Error(err)

		err = api.Save(home + "/.go140.oauth")
		if err != nil {
			fmt.Fprintf(os.Stderr, "Couldn't save authorization information: %s", err)
		}
	}

	return nil
}
Exemple #2
0
func authorize(api *go140.API) (err os.Error) {
	api.ConsumerKey = "no6XLKksvxtRHtS3aorzg"
	api.ConsumerSecret = "EJr4Nr9qcT7zjpuLTnmEnMPgNd0I0QEiDh6ksrjLWI"
	api.SignatureMethod = oauth.HMAC_SHA1

	api.RequestTokenURL = "https://api.twitter.com/oauth/request_token"
	api.OwnerAuthURL = "https://api.twitter.com/oauth/authorize"
	api.AccessTokenURL = "https://api.twitter.com/oauth/access_token"
	api.Callback = "oob"

	api.Root = "https://api.twitter.com"

	err = api.Load(authFile)
	if err != nil {
		err = api.GetRequestToken()
		processError(err)
		url, err := api.AuthorizationURL()
		processError(err)
		fmt.Printf("Please visit the following URL for authorization:\n%s\n", url)

		var verifier string
		fmt.Printf("PIN: ")
		fmt.Scanf("%s", &verifier)
		err = api.GetAccessToken(verifier)
		processError(err)

		err = api.Save(authFile)
		if err != nil {
			log.Println("Couldn't save authorization information", err)
		}
	}

	return nil
}