Oauth google fixes (#1330)
* Fix Auth Headers * Tweak Oauth to work for Google Co-authored-by: Ben Toogood <ben@micro.mu> Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
parent
eef4825be4
commit
20ce61da5a
@ -3,6 +3,7 @@ package oauth
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/auth/provider"
|
"github.com/micro/go-micro/v2/auth/provider"
|
||||||
)
|
)
|
||||||
@ -29,13 +30,19 @@ func (o *oauth) Options() provider.Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *oauth) Endpoint() string {
|
func (o *oauth) Endpoint() string {
|
||||||
var params url.Values
|
params := make(url.Values)
|
||||||
|
params.Add("response_type", "code")
|
||||||
|
|
||||||
if scope := o.opts.Scope; len(scope) > 0 {
|
if clientID := o.opts.ClientID; len(clientID) > 0 {
|
||||||
params.Add("scope", scope)
|
params.Add("client_id", clientID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if redir := o.opts.Redirect; len(redir) > 0 {
|
if scope := o.opts.Scope; len(scope) > 0 {
|
||||||
|
// spaces are url encoded since this cannot be passed in env vars
|
||||||
|
params.Add("scope", strings.ReplaceAll(scope, "%20", " "))
|
||||||
|
}
|
||||||
|
|
||||||
|
if redir := o.Redirect(); len(redir) > 0 {
|
||||||
params.Add("redirect_uri", redir)
|
params.Add("redirect_uri", redir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user