how to add authorization token in google rest api header

28 views
Skip to first unread message

Amitha Shenoy

unread,
Dec 23, 2022, 5:15:25 AM12/23/22
to Google Ads API and AdWords API Forum
Hi,


below is my code, i am getting unauthorized error


 ClickConversion clickConversion = new ClickConversion()
                        {
                            ConversionAction = ResourceNames.ConversionAction(123-123-1122, Int64.Parse(conversionActionId)),
                            ConversionDateTime = conversionTime,
                            CurrencyCode = "USD"
                        };

                        var request = (HttpWebRequest)WebRequest.Create("https://googleads.googleapis.com/v12/customers/123-123-1122:uploadClickConversions");
                        request.Method = "POST";
                        var data = new GoogleAdRequestBody("123-123-1122", new RepeatedField<ClickConversion> { clickConversion }, true, false);
                        using (var writer = new StreamWriter(request.GetRequestStream()))
                        {
                            writer.Write(data);
                        }
                        var webResponse = (HttpWebResponse)request.GetResponse();
                        result = webResponse.StatusCode;

I have added below setting to my json file

"GoogleAdsApi":
    {
        "DeveloperToken": "******",
        "OAuth2Mode": "APPLICATION",
        "OAuth2ClientId": "******.apps.googleusercontent.com",
        "OAuth2ClientSecret": "******",
        "OAuth2RefreshToken": "******",
    }

Google Ads API Forum Advisor

unread,
Dec 23, 2022, 11:43:06 AM12/23/22
to amitha...@indpro.se, adwor...@googlegroups.com
Hi Amitha,

I could see that you've created another forum thread with the same concerns mentioned in this case subject: Access Token. Please refrain from opening duplicate forum threads with the same content for better tracking of the issue. Let's continue our conversation on the other thread you've created as I already provide helpful support there.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


 

ref:_00D1U1174p._5004Q2hNAlA:ref
Reply all
Reply to author
Forward
0 new messages