मैं नेट में करते हैं। एक बार जब मैं प्राधिकरण प्रक्रिया और टोकन को सहेजता हूं, तो अगली बार जब मेरा उपयोगकर्ता साइट पर आता है तो मैं एक GOAuthRequestFactory ऑब्जेक्ट उत्पन्न करके प्राधिकरण खींचता हूं।
public GOAuthRequestFactory GetGoogleOAuthFactory(int id)
{
// build the base parameters
OAuthParameters parameters = new OAuthParameters
{
ConsumerKey = kConsumerKey,
ConsumerSecret = kConsumerSecret
};
// check to see if we have saved tokens and set
var tokens = (from a in context.GO_GoogleAuthorizeTokens where a.id = id select a);
if (tokens.Count() > 0)
{
GO_GoogleAuthorizeToken token = tokens.First();
parameters.Token = token.Token;
parameters.TokenSecret = token.TokenSecret;
}
// now build the factory
return new GOAuthRequestFactory("somevalue", kApplicationName, parameters);
}
एक बार मैं अनुरोध कारखाना है, मैं विभिन्न एपीआई कि मैं का उपयोग करें और इस तरह से कुछ करने के लिए अनुमति है में से एक कॉल कर सकते हैं:
// authenticate to the google calendar
CalendarService service = new CalendarService(kApplicationName);
service.RequestFactory = GetGoogleOAuthFactory([user id]);
// add from google doc record
EventEntry entry = new EventEntry();
entry.Title.Text = goEvent.Title;
entry.Content.Content = GoogleCalendarEventDescription(goEvent);
When eventTime = new When(goEvent.StartTime, goEvent.EndTime.HasValue ? goEvent.EndTime.Value : DateTime.MinValue, goEvent.AllDay);
entry.Times.Add(eventTime);
// add the location
Where eventLocation = new Where();
eventLocation.ValueString = String.Format("{0}, {1}, {2} {3}", goEvent.Address, goEvent.City, goEvent.State, goEvent.Zip);
entry.Locations.Add(eventLocation);
Uri postUri = new Uri(kCalendarURL);
// set the request and receive the response
EventEntry insertedEntry = service.Insert(postUri, entry);
मैं अभी भी क्या मैं गलत किया था पता नहीं है ; लेकिन किसी भी तरह से यह अब काम करता है! धन्यवाद – Rhapsody