1

I am using Google Plus API for .Net for implementing sharing on google plus using WebAuthenticationBroker. It returns a token after the user gets logged in but when I send a moments post request it returns error 401.

My code on clicking on image is

     String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://www.google.com&response_type=code&scope=" + Uri.EscapeDataString("https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.login");
                PlusService service = new PlusService();

                System.Uri StartUri = new Uri(GoogleURL);
                System.Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");
                WebAuthenticationBroker.AuthenticateAndContinue(new Uri(GoogleURL), EndUri);

now when it returns after authenticating I have called method upload on google in continue which is as follows--

PlusService service = new PlusService();
            Moment body = new Moment();               
            ItemScope itemScope = new ItemScope();

            itemScope.Id = "replacewithuniqueforaddtarget";
            itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
            itemScope.Type = "";
            itemScope.Description = "The description for the action";
            itemScope.Name = "An example of add activity";

            body.Object = itemScope;
            body.Type = "http://schema.org/AddAction";

            MomentsResource.InsertRequest insert =
                new MomentsResource.InsertRequest(
                    service,
                    body,
                    "me",
                    MomentsResource.InsertRequest.CollectionEnum.Vault);
            Moment wrote = insert.Execute();

But it returns exception 401. The code to post I found on Google Console Help. Can somebody help in this?

  • 1
    Moments insert requires that you send >setRequestVisibleActions() when creating the service. as far as I have been able to tell this is not possible with the client lib right now. I haven't had time to dig though the source code for the client lib to check though. I have a question like yours already posted http://stackoverflow.com/questions/27472937/google-moments-insert-unauthorized-error – Linda Lawton - DaImTo Feb 10 '15 at 13:11

1 Answers1

0

I finally found out that google APIs are not directly open to third party developers and it just made my case void and had to use HTTP method for this. Thanks @DalmTo for answering.