xjtuorg

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 14 Imported by: 0

README

XJTUORG

XJTU authentication module in Go

Usage
import (
	"net/http"
	"net/http/cookiejar"

    "github.com/endaytrer/xjtuorg"
)

// the parameter is whether to login as mobile

netid := "3124100000"
passwd := "password123"

// The login process would not begin before calling `Login`.
redir, err := xjtuorg.Login(true, "https://example.com/web/cas/login.html", netid, password)

if err != nil {
    // deal with error
}

// Now request with session to `redir`
client := http.Client{Jar: cookiejar.New(nil)}
_, err := client.Get(redir)

if err != nil {
    // deal with error
}

// Now you are logged in!
// Use `client` to make requests.

Documentation

Index

Constants

View Source
const Phase1Url = "https://org.xjtu.edu.cn/openplatform/g/admin/login"
View Source
const Phase2Url = "https://org.xjtu.edu.cn/openplatform/g/admin/getUserIdentity"
View Source
const Phase3Url = "https://org.xjtu.edu.cn/openplatform/oauth/auth/getRedirectUrl"

Variables

This section is empty.

Functions

func Login added in v1.1.0

func Login(mobile bool, login_url, username, password string) (redir_url string, err error)

Types

type ContentType

type ContentType string
const (
	None ContentType = "none"
	Json ContentType = "application/json"
	Form ContentType = "application/x-www-form-urlencoded"
)

type GeneralResponse

type GeneralResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type LoginError

type LoginError int
const (
	RequestError LoginError = iota
	ApiError
	NoIdentity
)

func (LoginError) Error

func (t LoginError) Error() string

type XjtuOrg

type XjtuOrg struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL