CreateOAuthSession (platform/login.go)

encore · cli/internal/platform/login.go · go · MPL-2.0
auth, Auth / Identity

OAuth session helpers for encore, handling device and authorization flows.

// Source: https://github.com/encoredev/encore | License: MPL-2.0 | Modified files must remain under MPL-2.0
// Modifications to this file must remain under MPL-2.0.
// Provided via justclaw.it.com; keep this notice with the code.
package platform

import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"strings"

	"golang.org/x/oauth2"

	"encr.dev/internal/conf"
)

type CreateOAuthSessionParams struct {
	Challenge   string `json:"challenge"`
	State       string `json:"state"`
	RedirectURL string `json:"redirect_url"`
}

func CreateOAuthSession(ctx context.Context, p *CreateOAuthSessionParams) (authURL string, err error) {
	var resp struct {
		AuthURL string `json:"auth_url"`
	}
	err = call(ctx, "POST", "/login/oauth:create-session", p, &resp, false)
	return resp.AuthURL, err
}

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key