2012-05-11 14 views
7

Nella documentazione di Google si diceCome per ottenere l'accesso a lunga durata del token di Google API

// Once the user authorizes with Google, the request token can be exchanged 
// for a long-lived access token. If you are building a browser-based 
// application, you should parse the incoming request token from the url and 
// set it in OAuthParameters before calling GetAccessToken(). 

ma non dice o mostrare come fare :(

Qualcuno sa come fare che per un'applicazione desktop?

campioni

codice sono più che benvenuti!

risposta

9

Ok, dopo un po 'di tempo l'ho risolto.

Dopo aver ottenuto un token di accesso, si ottiene anche un token di aggiornamento. archivia quel token!

fare anche questo parameters.AccessToken = StoredRefreshToken e parameters.RefreshToken = StoredRefreshToken prima di prendere la prossima richiesta di chiamata OAuthUtil.RefreshAccessToken(parameters);

E allora si dovrebbe essere pronti per fare una richiesta!

0

si sta utilizzando AuthSub with the .NET Client Library. Se è così, provate questo

if (Request.QueryString["token"] != null) 
{ 
    String token = Request.QueryString["token"]; 
    Session["token"] = AuthSubUtil.exchangeForSessionToken(token, null).ToString(); 
    Response.Redirect(Request.Url.AbsolutePath, true); 
}​ 

P.S: Il collegamento sopra riportato contiene l'elenco completo del codice.

+0

ottengo "Tentativo di aggiornamento di un token non aggiornabile" e questo è per l'app Web, sto creando un'app desktop. – Aviatrix

Problemi correlati