Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing documentation oauth2 variable + old method #205

Merged
merged 1 commit into from
Jul 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ func authorizeHandlerFunc(rw http.ResponseWriter, req *http.Request) {

// Let's create an AuthorizeRequest object!
// It will analyze the request and extract important information like scopes, response type and others.
ar, err := oauth2.NewAuthorizeRequest(ctx, req)
ar, err := oauth2Provider.NewAuthorizeRequest(ctx, req)
if err != nil {
oauth2.WriteAuthorizeError(rw, ar, err)
oauth2Provider.WriteAuthorizeError(rw, ar, err)
return
}

Expand Down Expand Up @@ -285,14 +285,14 @@ func authorizeHandlerFunc(rw http.ResponseWriter, req *http.Request) {
// Now we need to get a response. This is the place where the AuthorizeEndpointHandlers kick in and start processing the request.
// NewAuthorizeResponse is capable of running multiple response type handlers which in turn enables this library
// to support open id connect.
response, err := oauth2.NewAuthorizeResponse(ctx, ar, mySessionData)
response, err := oauth2Provider.NewAuthorizeResponse(ctx, ar, mySessionData)
if err != nil {
oauth2.WriteAuthorizeError(rw, ar, err)
oauth2Provider.WriteAuthorizeError(rw, ar, err)
return
}

// Awesome, now we redirect back to the client redirect uri and pass along an authorize code
oauth2.WriteAuthorizeResponse(rw, ar, response)
oauth2Provider.WriteAuthorizeResponse(rw, ar, response)
}

// The token endpoint is usually at "https://mydomain.com/oauth2/token"
Expand All @@ -301,9 +301,9 @@ func tokenHandlerFunc(rw http.ResponseWriter, req *http.Request) {
mySessionData := new(fosite.DefaultSession)

// This will create an access request object and iterate through the registered TokenEndpointHandlers to validate the request.
accessRequest, err := oauth2.NewAccessRequest(ctx, req, mySessionData)
accessRequest, err := oauth2Provider.NewAccessRequest(ctx, req, mySessionData)
if err != nil {
oauth2.WriteAccessError(rw, accessRequest, err)
oauth2Provider.WriteAccessError(rw, accessRequest, err)
return
}

Expand All @@ -313,14 +313,14 @@ func tokenHandlerFunc(rw http.ResponseWriter, req *http.Request) {

// Next we create a response for the access request. Again, we iterate through the TokenEndpointHandlers
// and aggregate the result in response.
response, err := oauth2.NewAccessResponse(ctx, accessRequest)
response, err := oauth2Provider.NewAccessResponse(ctx, accessRequest)
if err != nil {
oauth2.WriteAccessError(rw, accessRequest, err)
oauth2Provider.WriteAccessError(rw, accessRequest, err)
return
}

// All done, send the response.
oauth2.WriteAccessResponse(rw, accessRequest, response)
oauth2Provider.WriteAccessResponse(rw, accessRequest, response)

// The client has a valid access token now
}
Expand All @@ -330,7 +330,7 @@ func someResourceProviderHandlerFunc(rw http.ResponseWriter, req *http.Request)
mySessionData := new(fosite.DefaultSession)
requiredScope := "blogposts.create"

ar, err := oauth2.IntrospectToken(ctx, fosite.AccessTokenFromRequest(req), mySessionData, requiredScope)
ar, err := oauth2Provider.IntrospectToken(ctx, fosite.AccessTokenFromRequest(req), fosite.AccessToken, mySessionData, requiredScope)
if err != nil {
// ...
}
Expand Down