Working auth and photo json endpoint
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
ef275f97f4
commit
e4323b6047
2032 changed files with 821464 additions and 52 deletions
10
examples/curl.sh
Normal file
10
examples/curl.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
token="c558cccdd25917056e8b7b72a2a3e5f40215d707a6fac1aa"
|
||||
server="localhost"
|
||||
port="8080"
|
||||
|
||||
function photoget() {
|
||||
url="http://${server}:${port}/${1}"
|
||||
curl --header "X-Session-Id: ${token}" --header "Content-Type: application/json" ${url}
|
||||
}
|
10
examples/curl.sh~
Normal file
10
examples/curl.sh~
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
token=""
|
||||
server="localhost"
|
||||
port="8080"
|
||||
|
||||
function photoget() {
|
||||
url="http://${server}:${port}/${1}"
|
||||
curl --header "X-Session-Id: ${token}" --header "Content-Type: application/json" ${url} | jq
|
||||
}
|
17
examples/login.go
Normal file
17
examples/login.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
photoprism "github.com/kris-nova/client-go"
|
||||
"github.com/kris-nova/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger.Level = 4
|
||||
creds := photoprism.NewClientAuthLogin("admin", "missy")
|
||||
client := photoprism.New("localhost:8080")
|
||||
err := client.Auth(creds)
|
||||
if err != nil {
|
||||
halt(4, "Error logging into API: %v", err)
|
||||
}
|
||||
logger.Always("Login Success!")
|
||||
}
|
|
@ -9,13 +9,15 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
uuid := "pqnzigq156lndozm" // This is a known ID
|
||||
client := photoprism.New(auth())
|
||||
err := client.Login()
|
||||
logger.Level = 4
|
||||
uuid := "pqnzigq351j2fqgn" // This is a known ID
|
||||
creds := photoprism.NewClientAuthLogin("admin", "missy")
|
||||
client := photoprism.New("localhost:8080")
|
||||
err := client.Auth(creds)
|
||||
if err != nil {
|
||||
halt(4, "Error logging into API: %v", err)
|
||||
}
|
||||
logger.Always("Login Success!")
|
||||
//logger.Always("Login Success!")
|
||||
photo, err := client.V1().GetPhoto(uuid)
|
||||
if err != nil {
|
||||
halt(3, "Error fetching photo: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue