Code Monkey home page Code Monkey logo

go-auth0's People

Contributors

cluther avatar corntoole avatar joshw avatar rvykunta avatar seanmpope avatar srilathan10 avatar ssoleg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-auth0's Issues

Error when calling GroupsService::GetMembers(): panic: json: cannot unmarshal object into Go value of type []string

When I call this function, I found the returned []string is empty.

// GetMembers gets the members of a group
func (svc *GroupsService) GetMembers(groupID string) ([]string, error) {
var members []string
err := svc.c.Get("/api/groups/"+groupID+"/members", &members)
return members, err
}

After some debugging, I found that the json.Unmarshal() call fails with:

json: cannot unmarshal object into Go value of type []string

go-auth0/auth0/auth0.go

Lines 146 to 157 in 72da1c4

func readAndUnmarshal(r io.Reader, obj interface{}) error {
data, err := ioutil.ReadAll(r)
if err != nil {
return errors.Wrap(err, "Cannot read response body")
}
fmt.Printf("Response Body:\n%s\n\n", data)
err = json.Unmarshal(data, obj)
if err != nil {
return errors.Wrap(err, "Cannot unmarshal response")
}
return nil
}

The response's JSON body is like below:

{
	"total": 2,
	"users": [{
		"email": "[email protected]",
		"email_verified": false,
		"user_id": "auth0|5a7be5b6620e9c452a18c4c5",
		"picture": "https://s.gravatar.com/avatar/61cdbcb04d99fd3d37ec490366416bd3?s=480&r=pg&d=https://cdn.auth0.com/avatars/hs.png",
		"nickname": "xxx",
		"identities": [{
			"user_id": "5a7be5b6620e9c452a18c4c5",
			"provider": "auth0",
			"connection": "Username-Password-Authentication",
			"isSocial": false
		}],
		"updated_at": "2018-02-08T05:53:47.740Z",
		"created_at": "2018-02-08T05:52:54.535Z",
		"name": "[email protected]",
		"last_ip": "101.26.151.153",
		"last_login": "2018-02-08T05:53:47.740Z",
		"logins_count": 1
	}, {
		"email": "[email protected]",
		"email_verified": false,
		"user_id": "auth0|5a7f21c35c679b17810dee65",
		"picture": "https://s.gravatar.com/avatar/88502b57e6a1151ca2b5ba83e0e09480?s=480&r=pg&d=https://cdn.auth0.com/avatars/al.png",
		"identities": [{
			"connection": "Username-Password-Authentication",
			"user_id": "5a7f21c35c679b17810dee65",
			"provider": "auth0",
			"isSocial": false
		}],
		"updated_at": "2018-02-10T16:45:55.954Z",
		"created_at": "2018-02-10T16:45:55.954Z"
	}]
}

The above JSON string cannot be loaded into []string. I also add a panic here and the whole error stack is here:

panic: json: cannot unmarshal object into Go value of type []string [recovered]
	panic: json: cannot unmarshal object into Go value of type []string

goroutine 5 [running]:
testing.tRunner.func1(0xc0420ec0f0)

	C:/Go/src/testing/testing.go:711 +0x2d9
panic(0x694a00, 0xc04236e280)
	C:/Go/src/runtime/panic.go:491 +0x291
github.com/zenoss/go-auth0/auth0.readAndUnmarshal(0x2e00000, 0xc042196780, 0x6743c0, 0xc042378280, 0xc042196780, 0x18)
	C:/GoPath/src/github.com/zenoss/go-auth0/auth0/auth0.go:154 +0x1d9
github.com/zenoss/go-auth0/auth0.(*Auth0).Do(0xc042072c30, 0xc0422a4300, 0x6743c0, 0xc042378280, 0x0, 0x0)
	C:/GoPath/src/github.com/zenoss/go-auth0/auth0/auth0.go:182 +0x2be
github.com/zenoss/go-auth0/auth0/authz.(*AuthorizationService).Do(0xc04203c800, 0xc0422a4300, 0x6743c0, 0xc042378280, 0x831fc0, 0x887a78)
	C:/GoPath/src/github.com/zenoss/go-auth0/auth0/authz/authz.go:55 +0x58
github.com/zenoss/go-auth0/auth0/authz.(*AuthorizationService).Get(0xc04203c800, 0xc0422a2cc0, 0x38, 0x6743c0, 0xc042378280, 0x6ed9e8, 0x8)
	C:/GoPath/src/github.com/zenoss/go-auth0/auth0/authz/authz.go:64 +0x127
github.com/zenoss/go-auth0/auth0/authz.(*GroupsService).GetMembers(0xc04203ac70, 0xc042114870, 0x24, 0x6, 0xc0420fe308, 0x1, 0x0, 0x0)
	C:/GoPath/src/github.com/zenoss/go-auth0/auth0/authz/groups.go:102 +0xe4
github.com/casbin/auth0-role-manager.(*RoleManager).getAuth0GroupUsers(0xc0420e6230, 0x6ed46e, 0x6, 0x0, 0xc042072a80, 0xc04201a000, 0x7aa030, 0x7aa070)
	C:/GoPath/src/github.com/casbin/auth0-role-manager/role_manager.go:133 +0x162
github.com/casbin/auth0-role-manager.NewRoleManager(0x6f678b, 0x20, 0x6fcfb5, 0x40, 0x6ed8a8, 0x7, 0x6fccfe, 0x3e, 0xc005e55060, 0x7a6729)
	C:/GoPath/src/github.com/casbin/auth0-role-manager/role_manager.go:64 +0x1a2
github.com/casbin/auth0-role-manager.TestEnforcer(0xc0420ec0f0)
	C:/GoPath/src/github.com/casbin/auth0-role-manager/role_manager_test.go:87 +0x80
testing.tRunner(0xc0420ec0f0, 0x701bd0)
	C:/Go/src/testing/testing.go:746 +0xd7
created by testing.(*T).Run
	C:/Go/src/testing/testing.go:789 +0x2e5

Can this bug be fixed? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.