Fulfillment of the moments. Enable when using GTMOAuth2ViewControllerTouch for authentication

I am trying to insert "Moment" into a user Google+ account using google-api-objectivec-client library . I believe the authentication process is working correctly. This is primarily the same as having YouTube authentication installed, but with the correct scope and keyring name. However, when I try to run a query to insert a moment, I get the following error:

Domain Error = com.google.GTLJSONRPCErrorDomain Code = 401 "The operation could not be completed. (Unauthorized)"

Having studied the Google documentation more closely ( here ), I found the following comment:

When authenticating for instant.insert, you must enable it data-requestvisibleactionsto indicate what types of applications will be recorded by your application.

Google has a few examples of how to do this with other programming languages, but they don't have examples for the objective-c library, and the objective-c project does not contain examples of how to do this,

I know that there is another authentication method using the GPPSignIn button, which has a way to set actions. However, my application uses several other Google API clients (YouTube, YouTube Analytics, and URL Shortener). Mixing GoogleOpenSource.frameworkwith other objective-c libraries causes a conflict. Therefore, I need to use the GTMOAuth2ViewControllerTouch class.

My Authentication Code

    GTMOAuth2ViewControllerTouch *viewController =
    [GTMOAuth2ViewControllerTouch controllerWithScope:kGTLAuthScopePlusLogin
                                             clientID:kGoogleApiClientId
                                         clientSecret:kGoogleApiClientSecret
                                     keychainItemName:kGooglePlusKeychainName
                                    completionHandler:^(GTMOAuth2ViewControllerTouch *viewController, GTMOAuth2Authentication *auth, NSError *error) {

              if (error)
                  NSLog(@"Error: %@", error.description);
              else
                  app.googlePlusService.authorizer = auth; //this sets a property of my app delegate, to be used elsewhere in the application


    }];

    [self.navigationController pushViewController:viewController animated:YES];

The code I use to insert "Moment"

NSString *shareUrl = "http://www.google.com"; //just for this example

GTLPlusMoment *moment = [[GTLPlusMoment alloc] init];
moment.type = @"http://schemas.google.com/AddActivity";

GTLPlusItemScope *target = [[GTLPlusItemScope alloc] init];
target.url = shareUrl;
moment.target = target;

GTLQueryPlus *query =
[GTLQueryPlus queryForMomentsInsertWithObject:moment
                                       userId:@"me"
                                   collection:kGTLPlusCollectionVault];

[app.googlePlusService executeQuery:query
                  completionHandler:^(GTLServiceTicket *ticket,
                                      id object,
                                      NSError *error) {
     if (error) {
         NSLog(@"Got bad response from plus.moments.insert: %@", error);                     
     } else {
         NSLog(@"Moment inserted: %@",moment.identifier);
     }
 }];

- , data-requestvisibleactions , queryForMomentsInsertWithObject, moments.insert ?

!

+4
1

data-requestvisibleactions Java Script Authentication. authorized java script, . Objective c data-requestvisibleactions . Java Script.

.

0

All Articles