- Add GetToken() as unified auth entry point with method selection - Prompt [1] OAuth / [2] API token on first launch, save choice - Validate API tokens against /api/v1/users/self before saving - Check saved API token validity on reuse; fallback to re-prompt on failure - Add HTTP status check to GetCourseInfo and GetEnrolledCourses - Remove --api flag, auth method is now persistent and interactive
44 lines
998 B
Go
44 lines
998 B
Go
package models
|
|
|
|
type Credentials struct {
|
|
AuthMethod string `json:"auth_method,omitempty"`
|
|
RefreshToken string `json:"refresh_token,omitempty"`
|
|
APIToken string `json:"api_token,omitempty"`
|
|
}
|
|
|
|
type TokenResponse struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|
|
|
|
type Course struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type Folder struct {
|
|
ID int `json:"id"`
|
|
FullName string `json:"full_name"`
|
|
}
|
|
|
|
type File struct {
|
|
DisplayName string `json:"display_name"`
|
|
URL string `json:"url"`
|
|
FolderID int `json:"folder_id"`
|
|
}
|
|
|
|
type Module struct {
|
|
Name string `json:"name"`
|
|
Items []ModuleItem `json:"items"`
|
|
}
|
|
|
|
type ModuleItem struct {
|
|
Title string `json:"title"`
|
|
Type string `json:"type"`
|
|
URL string `json:"url"`
|
|
HTMLURL string `json:"html_url"`
|
|
ExternalURL string `json:"external_url"`
|
|
ContentID int `json:"content_id"`
|
|
Indent int `json:"indent"`
|
|
}
|