I was trying to run your example and ran into multiple problems. I fixed all those and was finally able to run the example on port 3846 as intended.
I have described my process stepwise below. There are two approaches, the second one solved the problem, the first one will bring to your notice an issue which I could not fix.
I could not send a pull request with my solution because the solution requires changes inside files in vendor directory. But this is generated by the glide install command. This is the reason why I tried first approach, but it brings to our notice a compatibility issue between latest commit of fosite and fosite-example.
Please have a look.
Approach 1:
go get github.com/Masterminds/glide
go get -d github.com/ory/fosite
C:\Users\Aman Kapoor>go get github.com/ory/fosite-example
github.com/ory/fosite-example/authorizationserver
C:\Gospace\src\github.com\ory\fosite-example\authorizationserver\oauth2.go:61: cannot use compose.OAuth2AuthorizeExplicitFactory (type func(compose.Config, interface {}, interface {}) interface {}) as type fosite.Hasher in argument to compose.Compose:
func(compose.Config, interface {}, interface {}) interface {} does not implement fosite.Hasher (missing Compare method)
So, I did go get -d -u github.com/ory/fosite-example and it worked. I did it because you suggested it in #5 (issue 5)
Next step according to you is to change the directory to fosite-example. Did that.
And then glide install
C:\Gospace\src\github.com\ory\fosite-example>glide install
[WARN] Lock file may be out of date. Hash check of YAML failed. You may need to run 'update'
[INFO] Downloading dependencies. Please wait...
[INFO] --> Fetching github.com/square/go-jose
[INFO] --> Fetching github.com/asaskevich/govalidator
[INFO] --> Fetching github.com/moul/http2curl
[INFO] --> Fetching github.com/ory/fosite
[INFO] --> Fetching github.com/golang/protobuf
[INFO] --> Fetching github.com/parnurzeal/gorequest
[INFO] --> Fetching github.com/pborman/uuid
[INFO] --> Fetching github.com/pkg/errors
[INFO] --> Fetching github.com/dgrijalva/jwt-go
[INFO] --> Fetching google.golang.org/appengine
[INFO] --> Fetching golang.org/x/crypto
[INFO] --> Fetching golang.org/x/net
[INFO] --> Fetching golang.org/x/oauth2
[INFO] Setting references.
[INFO] --> Setting version for github.com/dgrijalva/jwt-go to d2709f9f1f31ebcda9651b03077758c1f3a0018c.
[INFO] --> Setting version for github.com/parnurzeal/gorequest to 2aea80ce763523ecc6452e61c3727ae9595a5
809.
[INFO] --> Setting version for github.com/golang/protobuf to c3cefd437628a0b7d31b34fe44b3a7a540e98527.
[INFO] --> Setting version for github.com/asaskevich/govalidator to 7b3beb6df3c42abd3509abfc3bcacc0fbfb
7c877.
[INFO] --> Setting version for github.com/moul/http2curl to b1479103caacaa39319f75e7f57fc545287fca0d.
[INFO] --> Setting version for github.com/square/go-jose to aa2e30fdd1fe9dd3394119af66451ae790d50e0d.
[INFO] --> Setting version for github.com/pkg/errors to 645ef00459ed84a119197bfb8d8205042c6df63d.
[INFO] --> Setting version for github.com/pborman/uuid to a97ce2ca70fa5a848076093f05e639a89ca34d06.
[INFO] --> Setting version for github.com/ory/fosite to eb9077f6608d776ae50eb2ad4205705bad6ee0eb.
[INFO] --> Setting version for google.golang.org/appengine to b4728023490a62e70ba739ff62aa65ffcca84210.
[INFO] --> Setting version for golang.org/x/crypto to e0d166c33c321d0ff863f459a5882096e334f508.
[INFO] --> Setting version for golang.org/x/net to 075e191f18186a8ff2becaf64478e30f4545cdad.
[INFO] --> Setting version for golang.org/x/oauth2 to 04e1573abc896e70388bd387a69753c378d46466.
[INFO] Exporting resolved dependencies...
[INFO] --> Exporting github.com/asaskevich/govalidator
[INFO] --> Exporting github.com/golang/protobuf
[INFO] --> Exporting github.com/moul/http2curl
[INFO] --> Exporting github.com/ory/fosite
[INFO] --> Exporting github.com/parnurzeal/gorequest
[INFO] --> Exporting github.com/dgrijalva/jwt-go
[INFO] --> Exporting github.com/pborman/uuid
[INFO] --> Exporting github.com/pkg/errors
[INFO] --> Exporting github.com/square/go-jose
[INFO] --> Exporting google.golang.org/appengine
[INFO] --> Exporting golang.org/x/crypto
[INFO] --> Exporting golang.org/x/net
[INFO] --> Exporting golang.org/x/oauth2
[INFO] Replacing existing vendor dependencies
I changed glide.yaml file and glide.lock file to have 0.8.0 and 349726028d42f3c60aeefc67aef06f9f907ccf94 (your latest commit when writing this issue)
And then I do glide install.
Then I do go install, which gives this
C:\Gospace\src\github.com\ory\fosite-example>go install
github.com/ory/fosite-example/authorizationserver
authorizationserver\oauth2.go:61: cannot use compose.OAuth2AuthorizeExplicitFactory (type func(compose.
Config, interface {}, interface {}) interface {}) as type fosite.Hasher in argument to compose.Compose:
func(compose.Config, interface {}, interface {}) interface {} does not implement fosite.Hasher
(missing Compare method)
This error is same as in step 3.
Approach 2 which worked.
Step 1: Do step 6 of approach 1.
Step 2: Find and replace ory-am with ory in all the files under fosite-example folder. (Most of these changes will be done under vendor\github.com\ory\fosite; around 109 files are there)
Step 3: go install
C:\Gospace\src\github.com\ory\fosite-example>go install
github.com/ory/fosite-example/authorizationserver
authorizationserver\oauth2_auth.go:81: not enough arguments in call to oauth2.NewAuthorizeResponse
have ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, fosite.AuthorizeRequester, openid.DefaultSession)
want ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, http.Request, fosite.AuthorizeRequester, fosite.Session)
authorizationserver\oauth2_token.go:40: not enough arguments in call to oauth2.NewAccessResponse
have ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, fosite.AccessRequester)
want ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, *http.Request, fosite.AccessRequester)
Step 4: To fix first error in Step 3, I go to this piece of code authorizationserver\oauth2_auth.go:81: and change response, err := oauth2.NewAuthorizeResponse(ctx, ar, mySessionData) to response, err := oauth2.NewAuthorizeResponse(ctx, req, ar, mySessionData)
Step 5: To fix second error in Step 3, I go to this piece of code authorizationserver\oauth2_token.go:40: and change response, err := oauth2.NewAccessResponse(ctx, accessRequest) to response, err := oauth2.NewAccessResponse(ctx, req, accessRequest)
Step 4: go install and it works.
PS: In my first time, when I downloaded this example, I fixed it using second approach only. But then I thought why should we find and replace, and instead I imported the latest commit of fosite, and this way the first approach and its reccuring error came into existence. Your latest fosite code is not working with fosite-example, and I could not fix it. I hope you make necessary changes in latest code to make it work.
I am learning to integrate it in my site that I am building.
I was trying to run your example and ran into multiple problems. I fixed all those and was finally able to run the example on port 3846 as intended.
I have described my process stepwise below. There are two approaches, the second one solved the problem, the first one will bring to your notice an issue which I could not fix.
I could not send a pull request with my solution because the solution requires changes inside files in vendor directory. But this is generated by the
glide install
command. This is the reason why I tried first approach, but it brings to our notice a compatibility issue between latest commit of fosite and fosite-example.Please have a look.
Approach 1:
go get github.com/Masterminds/glide
go get -d github.com/ory/fosite
C:\Users\Aman Kapoor>
go get github.com/ory/fosite-example
github.com/ory/fosite-example/authorizationserver C:\Gospace\src\github.com\ory\fosite-example\authorizationserver\oauth2.go:61: cannot use compose.OAuth2AuthorizeExplicitFactory (type func(compose.Config, interface {}, interface {}) interface {}) as type fosite.Hasher in argument to compose.Compose: func(compose.Config, interface {}, interface {}) interface {} does not implement fosite.Hasher (missing Compare method)So, I did
go get -d -u github.com/ory/fosite-example
and it worked. I did it because you suggested it in #5 (issue 5)Next step according to you is to change the directory to fosite-example. Did that.
And then
glide install
C:\Gospace\src\github.com\ory\fosite-example>glide install [WARN] Lock file may be out of date. Hash check of YAML failed. You may need to run 'update' [INFO] Downloading dependencies. Please wait... [INFO] --> Fetching github.com/square/go-jose [INFO] --> Fetching github.com/asaskevich/govalidator [INFO] --> Fetching github.com/moul/http2curl [INFO] --> Fetching github.com/ory/fosite [INFO] --> Fetching github.com/golang/protobuf [INFO] --> Fetching github.com/parnurzeal/gorequest [INFO] --> Fetching github.com/pborman/uuid [INFO] --> Fetching github.com/pkg/errors [INFO] --> Fetching github.com/dgrijalva/jwt-go [INFO] --> Fetching google.golang.org/appengine [INFO] --> Fetching golang.org/x/crypto [INFO] --> Fetching golang.org/x/net [INFO] --> Fetching golang.org/x/oauth2 [INFO] Setting references. [INFO] --> Setting version for github.com/dgrijalva/jwt-go to d2709f9f1f31ebcda9651b03077758c1f3a0018c. [INFO] --> Setting version for github.com/parnurzeal/gorequest to 2aea80ce763523ecc6452e61c3727ae9595a5 809. [INFO] --> Setting version for github.com/golang/protobuf to c3cefd437628a0b7d31b34fe44b3a7a540e98527. [INFO] --> Setting version for github.com/asaskevich/govalidator to 7b3beb6df3c42abd3509abfc3bcacc0fbfb 7c877. [INFO] --> Setting version for github.com/moul/http2curl to b1479103caacaa39319f75e7f57fc545287fca0d. [INFO] --> Setting version for github.com/square/go-jose to aa2e30fdd1fe9dd3394119af66451ae790d50e0d. [INFO] --> Setting version for github.com/pkg/errors to 645ef00459ed84a119197bfb8d8205042c6df63d. [INFO] --> Setting version for github.com/pborman/uuid to a97ce2ca70fa5a848076093f05e639a89ca34d06. [INFO] --> Setting version for github.com/ory/fosite to eb9077f6608d776ae50eb2ad4205705bad6ee0eb. [INFO] --> Setting version for google.golang.org/appengine to b4728023490a62e70ba739ff62aa65ffcca84210.
[INFO] --> Setting version for golang.org/x/crypto to e0d166c33c321d0ff863f459a5882096e334f508. [INFO] --> Setting version for golang.org/x/net to 075e191f18186a8ff2becaf64478e30f4545cdad. [INFO] --> Setting version for golang.org/x/oauth2 to 04e1573abc896e70388bd387a69753c378d46466. [INFO] Exporting resolved dependencies... [INFO] --> Exporting github.com/asaskevich/govalidator [INFO] --> Exporting github.com/golang/protobuf [INFO] --> Exporting github.com/moul/http2curl [INFO] --> Exporting github.com/ory/fosite [INFO] --> Exporting github.com/parnurzeal/gorequest [INFO] --> Exporting github.com/dgrijalva/jwt-go [INFO] --> Exporting github.com/pborman/uuid [INFO] --> Exporting github.com/pkg/errors [INFO] --> Exporting github.com/square/go-jose [INFO] --> Exporting google.golang.org/appengine [INFO] --> Exporting golang.org/x/crypto [INFO] --> Exporting golang.org/x/net [INFO] --> Exporting golang.org/x/oauth2 [INFO] Replacing existing vendor dependencies
go install
vendor\github.com\ory\fosite\compose\compose.go:6:2: cannot find package "github.com/ory-am/fosite" in any of: C:\Gospace\src\github.com\ory\fosite-example\vendor\github.com\ory-am\fosite (vendor tree) C:\Go\src\github.com\ory-am\fosite (from $GOROOT) C:\Gospace\src\github.com\ory-am\fosite (from $GOPATH) vendor\github.com\ory\fosite\compose\compose_oauth2.go:5:2: cannot find package "github.com/ory-am/fosite/handler/oauth2" in any of: C:\Gospace\src\github.com\ory\fosite-example\vendor\github.com\ory-am\fosite\handler\oauth2 (vendor tree) C:\Go\src\github.com\ory-am\fosite\handler\oauth2 (from $GOROOT) C:\Gospace\src\github.com\ory-am\fosite\handler\oauth2 (from $GOPATH) vendor\github.com\ory\fosite\compose\compose_openid.go:6:2: cannot find package "github.com/ory-am/fosite/handler/openid" in any of: C:\Gospace\src\github.com\ory\fosite-example\vendor\github.com\ory-am\fosite\handler\openid (vendor tree) C:\Go\src\github.com\ory-am\fosite\handler\openid (from $GOROOT) C:\Gospace\src\github.com\ory-am\fosite\handler\openid (from $GOPATH) vendor\github.com\ory\fosite\compose\compose_strategy.go:8:2: cannot find package "github.com/ory-am/fosite/token/hmac" in any of: C:\Gospace\src\github.com\ory\fosite-example\vendor\github.com\ory-am\fosite\token\hmac (vendor tree) C:\Go\src\github.com\ory-am\fosite\token\hmac (from $GOROOT) C:\Gospace\src\github.com\ory-am\fosite\token\hmac (from $GOPATH) vendor\github.com\ory\fosite\compose\compose_strategy.go:9:2: cannot find package "github.com/ory-am/fosite/token/jwt" in any of: C:\Gospace\src\github.com\ory\fosite-example\vendor\github.com\ory-am\fosite\token\jwt (vendor tree) C:\Go\src\github.com\ory-am\fosite\token\jwt (from $GOROOT) C:\Gospace\src\github.com\ory-am\fosite\token\jwt (from $GOPATH)
This problem is because of change from ory-am to ory and glide installs this version of your repo https://github.com/ory/fosite/commit/eb9077f6608d776ae50eb2ad4205705bad6ee0eb
I changed glide.yaml file and glide.lock file to have 0.8.0 and 349726028d42f3c60aeefc67aef06f9f907ccf94 (your latest commit when writing this issue)
And then I do glide install.
Then I do go install, which gives this C:\Gospace\src\github.com\ory\fosite-example>go install
github.com/ory/fosite-example/authorizationserver authorizationserver\oauth2.go:61: cannot use compose.OAuth2AuthorizeExplicitFactory (type func(compose. Config, interface {}, interface {}) interface {}) as type fosite.Hasher in argument to compose.Compose: func(compose.Config, interface {}, interface {}) interface {} does not implement fosite.Hasher (missing Compare method)
This error is same as in step 3.
Approach 2 which worked.
Step 1: Do step 6 of approach 1.
Step 2: Find and replace ory-am with ory in all the files under fosite-example folder. (Most of these changes will be done under vendor\github.com\ory\fosite; around 109 files are there)
Step 3:
go install
C:\Gospace\src\github.com\ory\fosite-example>go install github.com/ory/fosite-example/authorizationserver authorizationserver\oauth2_auth.go:81: not enough arguments in call to oauth2.NewAuthorizeResponse have ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, fosite.AuthorizeRequester, openid.DefaultSession) want ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, http.Request, fosite.AuthorizeRequester, fosite.Session) authorizationserver\oauth2_token.go:40: not enough arguments in call to oauth2.NewAccessResponse have ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, fosite.AccessRequester) want ("github.com/ory/fosite-example/vendor/golang.org/x/net/context".Context, *http.Request, fosite.AccessRequester)Step 4: To fix first error in Step 3, I go to this piece of code authorizationserver\oauth2_auth.go:81: and change response, err := oauth2.NewAuthorizeResponse(ctx, ar, mySessionData) to response, err := oauth2.NewAuthorizeResponse(ctx, req, ar, mySessionData)
Step 5: To fix second error in Step 3, I go to this piece of code authorizationserver\oauth2_token.go:40: and change response, err := oauth2.NewAccessResponse(ctx, accessRequest) to response, err := oauth2.NewAccessResponse(ctx, req, accessRequest)
Step 4:
go install
and it works.PS: In my first time, when I downloaded this example, I fixed it using second approach only. But then I thought why should we find and replace, and instead I imported the latest commit of fosite, and this way the first approach and its reccuring error came into existence. Your latest fosite code is not working with fosite-example, and I could not fix it. I hope you make necessary changes in latest code to make it work.
I am learning to integrate it in my site that I am building.