Problemi Google Api

di Anonimizzato21367 il
7 risposte
Ciao a tutti sto facendo una piccola applicazione che mi permette di sincronizzare i miei contatti con quelli presenti sul telefono...

tutto bene poi ad un certo punto, dopo un po di ingressi ottengo questo errore...

Google.GData.Client.GDataRequestException: 'Execution of request failed: https://www.google.com/m8/feeds/contacts/default/full?max-results=2000'


qualcuno ha avuto la stessa problematica???

la cosa che mi lascia basito è che va a volte si a volte no...

7 Risposte

  • Che codice http ti ritorna?
  • Ti scrivo l'eccezione ...
    sono in c#

    Google.GData.Client.GDataRequestException
    HResult=0x80131500
    Message=Execution of request failed:
    Source=Google.GData.Client
    StackTrace:
    at Google.GData.Client.GOAuth2Request.Execute()
    at Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince, String etag, Int64& contentLength)
    at Google.GData.Client.Service.Query(FeedQuery feedQuery)
    at Google.GData.Client.Feed`1.get_AtomFeed()
    at Google.GData.Client.Feed`1.<get_Entries>d__0.MoveNext()
    at EZ.Common.WebFunctions.GContacts.GContacts.HaveAllContacts(Int32 MaxNumbers) in F:\MyProjectAtWork\EZFunctions\Common\WebFunctions\GContacts\GContacts.cs:line 41
    at WASDGest.Windows._Support.frmContactListener.updateGrid() in F:\MyProjectAtWork\WASDGest\Windows\_Support\frmContactListener.cs:line 34
    at WASDGest.Windows._Support.frmContactListener.BtnUpdate_Click(Object sender, EventArgs e) in F:\MyProjectAtWork\WASDGest\Windows\_Support\frmContactListener.cs:line 66
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at WASDGest.Program.Main() in F:\MyProjectAtWork\WASDGest\Program.cs:line 39

    Inner Exception 1:
    WebException: Errore del server remoto: (401) Non autorizzato.
  • È da notare che stamattina andava...
    ieri sera a casa andava...
    ieri mattina andava
    stesso codice
  • Codice 401 (non autorizzato).
    E' possibile che sia un problema di token scaduto? Che poi ogni tanto riaggiorni passando per altre vie?
    Qui https://developers.google.com/identity/sign-in/android/backend-auth in "Verify the integrity of the ID token" ti dice come controllare che il token non sia scaduto.
  • Ho visto ma non capisco come posso richiedere il token in caso sia scaduto...
    indipendentemente da tutto vorrei evitare di dover richiedere l'autorizzazione tutte le volte che mi scade...
  • Qui è dove faccio la richiesta alla API
    
     string clientId = "YES IT WORKS";
                string clientSecret = "YES IT WORKS";
    
    
                string[] scopes =
                    new string[] { "https://www.google.com/m8/feeds/" };     // view your basic profile info.
                try
                {
                    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
                    {
                        ClientId = clientId,
                        ClientSecret = clientSecret
                    },
                    scopes,
                    "default",
                    CancellationToken.None).Result;
                   
                    OAuth2Parameters parameters = new OAuth2Parameters();
    
                    parameters.AccessToken = credential.Token.AccessToken;
                    parameters.RefreshToken = credential.Token.RefreshToken;
    
                    "Autorizzazione eseguita con Successo".LogInfo();
                    return parameters;
                }
                catch (Exception ex)
                {
                    ex.ToString().LogError();
                    return null;
                }
    
    e qui dove sfrutto i parametri ottenuti...
    mi sembra che il Token venga aggiornato ad ogni chiamata.... [CODE] var parameters = GAuth.auth(); RequestSettings settings = new RequestSettings("sssss", parameters); _cr = new ContactsRequest(settings);
  • Sembra il problema sia sistemato...

    Segno di seguito le correzioni al codice se vi potessero essere utili
           
                    OAuth2Parameters parameters = new OAuth2Parameters();
                    parameters.ClientId = clientId;
                    parameters.ClientSecret = clientSecret;
                    
                    parameters.AccessToken = accessToken;//credential.Token.AccessToken;
                    parameters.RefreshToken = refreshToken;//credential.Token.RefreshToken;
    
    riforzando l'inerimento dei parametri nel token sembra funzionare tutto
Devi accedere o registrarti per scrivere nel forum
7 risposte