<https://lh3.googleusercontent.com/-4HQCp0tbviE/U8fic3a42II/AAAAAAAAAIg/g7yBQtbjR0c/s1600/campaign.png>

<https://lh6.googleusercontent.com/-vefVy9qtwYM/U8fiPItm1eI/AAAAAAAAAIY/fXsPNJMJb7U/s1600/accept.jpg>

<https://lh5.googleusercontent.com/-d8XtCBZPhSk/U8fiBHcFMNI/AAAAAAAAAIQ/QYzEdMyoVoA/s1600/login.png>

Hi ,

 

I downloaded the google adwords dotnet library with examples 

 

I ran  the Oauth Project (…….examples\AdWords\csharp\oauth) 

 

THis project has two aspx pages 

 

I just added some code in the below function as follows 

 

   private void DoAuth2Configuration(AdWordsAppConfig config) {

 

            config.Email = "t...@gmail.com";

                config.Password = "xxxxxxxxxxx!";

                config.UserAgent = "xxxxxxxxxxxx";

                config.DeveloperToken = "xxxxxxxxxxxxxxxxx";

                config.AuthorizationMethod = AdWordsAuthorizationMethod
.OAuth2;

                config.ClientCustomerId = "123-456-789".ToString().Replace(
"-", "");

                config.OAuth2ClientId = 
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com";

                config.OAuth2ClientSecret = "_xxxxxxxxxxxxxxxxxxxxxxxxx";

       

                config.OAuth2RedirectUri = Request.Url.GetLeftPart(
UriPartial.Path);

      // Create an OAuth2 object for handling OAuth2 flow.

      OAuth2ProviderForApplications oAuth = new 
OAuth2ProviderForApplications(config);

      if (Request.Params["state"] == null) {

        // This is the first time this page is being loaded.

        // Set the state variable to any value that helps you recognize

        // when this url will be called by the OAuth2 server.

        oAuth.State = "callback";

 

        // Create an authorization url and redirect the user to that page.

        Response.Redirect(oAuth.GetAuthorizationUrl());

      } else if (Request.Params["state"] == "callback") {

 

        oAuth.FetchAccessAndRefreshTokens(Request.Params["code"]);

 

        Session["OAuthProvider"] = oAuth;

        // Redirect the user to the main page.

        Response.Redirect("Default.aspx");

      } else {

        throw new Exception("Unknown state for OAuth callback.");

      }

    }

 

And then ran the application I was redirect to my google account  below 
screen 

<https://lh5.googleusercontent.com/-d8XtCBZPhSk/U8fiBHcFMNI/AAAAAAAAAIQ/QYzEdMyoVoA/s1600/login.png>

 

 

step 1 :After Entering Credentials I was redirected to the below screen 

<https://lh6.googleusercontent.com/-vefVy9qtwYM/U8fiPItm1eI/AAAAAAAAAIY/fXsPNJMJb7U/s1600/accept.jpg>

 

 

Step 2 : After clicking Accept I was redirected to the default.aspx

 

 
<https://lh3.googleusercontent.com/-4HQCp0tbviE/U8fic3a42II/AAAAAAAAAIg/g7yBQtbjR0c/s1600/campaign.png>

 

 *After Entering the Customer ID I was able to get the Campaign Details*

 

*In this I came across that I need to login into my google adwords  Account 
, Click Accept *

*In which the Application redirects an authoriztion URL When I click accept 
I receive an authorization code *

*Which I use to Fetch Access And Refresh Tokens Which is then used by the 
google api (camapign Service )*

*to get the campaign Details*

 

*Is there any way in which I can avoid the steps 1 and 2 so that I don’t 
need to  Login and click Accept*

 

*Is there any way I can get the authorization code directly and use it to 
Fetch Access And Refresh Tokens*

 

*As I have a web application in which my clients use the api to get 
campaign details and statistics of campaign *

*I don’t want then to go through these steps *

 

*Please Suggest  *

 

*Thanks and Regards *

*Altaf*

 

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to