MCPcopy Create free account
hub / github.com/auth0/auth0-cli / BuildLoginURL

Function BuildLoginURL

internal/auth/authutil/login.go:10–47  ·  view source on GitHub ↗

BuildLoginURL constructs a URL + query string that can be used to initiate a user-facing login-flow from the CLI.

(domain, clientID, callbackURL, state, connectionName, audience, prompt string, scopes []string, customParams map[string]string)

Source from the content-addressed store, hash-verified

8// BuildLoginURL constructs a URL + query string that can be used to
9// initiate a user-facing login-flow from the CLI.
10func BuildLoginURL(domain, clientID, callbackURL, state, connectionName, audience, prompt string, scopes []string, customParams map[string]string) (string, error) {
11 q := url.Values{}
12 q.Add("client_id", clientID)
13 q.Add("response_type", "code")
14 q.Add("redirect_uri", callbackURL)
15 q.Add("state", state)
16
17 if prompt != "" {
18 q.Add("prompt", prompt)
19 }
20
21 if connectionName != "" {
22 q.Add("connection", connectionName)
23 }
24
25 if audience != "" {
26 q.Add("audience", audience)
27 }
28
29 if len(scopes) > 0 {
30 q.Add("scope", strings.Join(scopes, " "))
31 }
32
33 if len(customParams) > 0 {
34 for k, v := range customParams {
35 q.Add(k, v)
36 }
37 }
38
39 u := &url.URL{
40 Scheme: "https",
41 Host: domain,
42 Path: "/authorize",
43 RawQuery: q.Encode(),
44 }
45
46 return u.String(), nil
47}

Callers 2

runLoginFlowFunction · 0.92
TestBuildLoginURLFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestBuildLoginURLFunction · 0.68