schmorrison / Zoho

Golang API for Zoho services
MIT License
35 stars 34 forks source link

Not able to get data consistently, no errors #9

Closed beatscode closed 5 years ago

beatscode commented 5 years ago

Trying to follow the example on the home page. When I first create the api client id and use the library it seems to work initially but all subsequent requests return empty data response. No errors just empty. Am I missing something? Is the code retrieval cached I tried taking the code GET parameter and just using z.GenerateTokenRequest but this returns empty response as well. I tried removing the .tokens.zoho file and tried again same outcome.

schmorrison commented 5 years ago

Thanks for the comment, I haven't experienced this so can you provide a minimal code sample that produces the problems you are seeing.

beatscode commented 5 years ago
package main

import (
    "fmt"
    "github.com/schmorrison/Zoho"
    "github.com/schmorrison/Zoho/crm"
    "log"
    "testing"
)

func TestZohoCRM(t *testing.T) {
    // Create a new Zoho object
    z := zoho.New()
    // to start oAuth2 flow
    //scopes := []zoho.ScopeString{
    //  zoho.BuildScope(zoho.Crm, zoho.ModulesScope, zoho.AllMethod, zoho.NoOp),
    //}
    clientid := "XXXXX"
    secret := "XXXX"
    code := "XXXX"

    redirecturl := "http://localhost:8081/oauthcallback"
        // I would try this first.. Click the link and get the code from the url 
    //if err := z.AuthorizationCodeRequest(clientid, secret, scopes, redirecturl); err != nil {
    //  log.Fatal(err)
    //}

    err := z.GenerateTokenRequest(clientid, secret, code, redirecturl)
    if err != nil {
        log.Fatal(err)
    }
    // Create a new CRM object and provide the zoho master struct
    c := crm.New(z)

    data := crm.Account{}
    r, err := c.ListRecords(&data, crm.AccountsModule, nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("Data", data)
    fmt.Println("Response", r)

}
schmorrison commented 5 years ago

Closing. Reopen if you find this issue again.

Thanks again for tracking down my mistakes!!!