google api - How to correctly setup Oauth 2 Authentication in YouTube V3 API -


i have console app pulls video view counts data using youtube v3 api. using oauth 2 authentication , having issues.

i executed application on 2 different servers @ different times.

one machines authenticates , returns following message logs:

2013-05-08 09:51:45,691 [8] info  dotnetopenauth.messaging.channel - prepared outgoing accesstokenrefreshrequest (2.0) message https://accounts.google.com/o/oauth2/token:  refresh_token: 1/m4pjx978kbegkqtf6tvsjdfczej1na6nbtakhhhqkjs grant_type: refresh_token client_id: 1085346326111.apps.googleusercontent.com client_secret: hhh5wfqtrdxml54rnzaughna 

the other doesn’t authenticate , assuming waiting permission submit youtube data api requests on user's behalf:

2013-05-08 09:44:59,442 [31] info dotnetopenauth.messaging.channel - prepared outgoing enduserauthorizationrequest (2.0) message https://accounts.google.com/o/oauth2/auth: response_type: code client_id: 1085346326111.apps.googleusercontent.com redirect_uri:server local host path scope: https://www.googleapis.com/auth/youtube.readonly

can give me explanation why app may not able authenticate on 1 server based on fact both servers using same code, same clientid , same secret key?

here snippet of code:

private void oauth2authenticate() {

        try         {              var provider = new nativeapplicationclient(googleauthenticationserver.description)                 {                     clientidentifier = configurationmanager.appsettings["client.id"],                     clientsecret = configurationmanager.appsettings["client.secret"]                   };              var auth = new oauth2authenticator<nativeapplicationclient>(provider, getauthorization);              youtube = new youtubeservice(new baseclientservice.initializer()                 {                     authenticator = auth                 });         }         catch (exception e)         {             if (logger != null)             logger.error(string.format("error authenticating aplication on youtube authentiction server", e.message), e);         }      }        private static iauthorizationstate getauthorization(nativeapplicationclient client)     {         var storage = methodbase.getcurrentmethod().declaringtype.tostring();          var key = "storage_key";          iauthorizationstate state = authorizationmgr.getcachedrefreshtoken(storage, key);         if (state != null)         {             client.refreshtoken(state);         }         else         {             state = authorizationmgr.requestnativeauthorization(client, youtubeservice.scopes.youtubereadonly.getstringvalue());             authorizationmgr.setcachedrefreshtoken(storage, key, state);         }          return state;     } 


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -