Example #1
0
func HandleInitialClientRedirect(w http.ResponseWriter, req *http.Request) {
	client := oauth2_client.NewGoogleClient()
	client.Initialize(settings)
	tokenUrl := client.GenerateRequestTokenUrl(jsonhelper.NewJSONObject())
	if len(tokenUrl) > 0 {
		w.Header().Set("Location", tokenUrl)
		w.WriteHeader(302)
	} else {
		w.WriteHeader(500)
	}
}
Example #2
0
func NewMockGoogleClient() *MockGoogleClient {
	client := oauth2_client.NewMockOAuthClient()
	m := &MockGoogleClient{
		MockClient:   client,
		contactsById: make(map[string]*Contact),
		groupsById:   make(map[string]*ContactGroup),
	}
	gclient := oauth2_client.NewGoogleClient()
	client.SetServiceId(gclient.ServiceId())
	client.SetRequestHandler(makeHandlerForGoogleClientRequests(m))
	return m
}
Example #3
0
func HandleSuccessfulLogin(w http.ResponseWriter, req *http.Request) {
	client := oauth2_client.NewGoogleClient()
	client.Initialize(settings)
	client.ExchangeRequestTokenForAccess(req)
	useReq, _ := client.CreateAuthorizedRequest("GET", nil, GOOGLE_CONTACTS_TEST_URL, nil, nil)
	resp, _, _ := oauth2_client.MakeRequest(client, useReq)
	h := w.Header()
	if resp != nil {
		for k, v := range resp.Header {
			for _, v1 := range v {
				h.Add(k, v1)
			}
		}
		w.WriteHeader(resp.StatusCode)
		io.Copy(w, resp.Body)
	}
}
Example #4
0
func NewGoogleOauth2ClientTester(properties jsonhelper.JSONObject) oauth2_client.OAuth2Client {
	c := oauth2_client.NewGoogleClient()
	c.Initialize(properties)
	return c
}
Example #5
0
func (p *GoogleContactService) CreateOAuth2Client(settings jsonhelper.JSONObject) (client oauth2_client.OAuth2Client, err os.Error) {
	client = oauth2_client.NewGoogleClient()
	client.Initialize(settings)
	return
}
func HandleGoogleOauthTestRequest(w http.ResponseWriter, req *http.Request) {
	HandleGenericOauthTestRequest(w, req, oauth2_client.NewGoogleClient(), oauth2_client.GET, "google.client.test_url", "", PARSED_GOOGLE_TEMPLATE)
}