Skip to content

Instantly share code, notes, and snippets.

@eytanschulman
Created September 8, 2014 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eytanschulman/832d97c286c3e9fb2590 to your computer and use it in GitHub Desktop.
Save eytanschulman/832d97c286c3e9fb2590 to your computer and use it in GitHub Desktop.
WBAIS App API Request
-(void)executeCalendarRequest {
NSString *clientID = [[[GPPSignIn sharedInstance] authentication] clientID];
NSString *clientSecret = @"z4TA1SX2O9Fmf0Xr76-HASBy";
NSString *accessToken = [[[GPPSignIn sharedInstance] authentication] accessToken];
NSLog(@"clientID = %@",clientID);
NSLog(@"clientSecret = %@",clientSecret);
NSLog(@"accessToken = %@",accessToken);
[nameLabel setText:[NSString stringWithFormat:@"%@ %@",globalPerson.name.givenName,globalPerson.name.familyName]];
// [self.googleOAuth authorizeUserWithClienID:clientID
// andClientSecret:clientSecret
// andParentView:self.view
// andScopes:[NSArray arrayWithObject:@"https://www.googleapis.com/auth/calendar"]];
// NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/calendar/v3/users/me/calendarList/access_token=1/%@",[[[GPPSignIn sharedInstance] authentication] accessToken]];
NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/calendar/v3/users/me/calendarList/&key=%@",[[GPPSignIn sharedInstance] authentication].accessToken];
// NSString *requestURL = [NSString stringWithFormat:@"https://www.googleapis.com/auth/calendar?%@",[[GPPSignIn sharedInstance] authentication].accessToken];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10];
[request setHTTPMethod: @"GET"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[self makeRequest:request];
}
//This method gets ran when the data comes in from the server, and logs the response
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
// Append any new data to the _receivedData object.
[_receivedData appendData:data];
NSLog(@"receivedData = %@",_receivedData);
NSLog(@"data = %@",data);
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&error];
NSLog(@"json = %@",json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment