Skip to content

Commit a457732

Browse files
committed
fixes #27 by switching to /auth/currentCredential for client validation
1 parent bd61794 commit a457732

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ovh/config.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ovh
33
import (
44
"fmt"
55
"log"
6+
"time"
67

78
"github.com/ovh/go-ovh/ovh"
89
)
@@ -15,10 +16,15 @@ type Config struct {
1516
OVHClient *ovh.Client
1617
}
1718

18-
/* type used to verify client access to ovh api
19-
*/
20-
type PartialMe struct {
21-
Firstname string `json:"firstname"`
19+
type OvhAuthCurrentCredential struct {
20+
OvhSupport bool `json:"ovhSupport"`
21+
Status string `json:"status"`
22+
ApplicationId int64 `json:"applicationId"`
23+
CredentialId int64 `json:"credentialId"`
24+
Rules []ovh.AccessRule `json:"rules"`
25+
Expiration time.Time `json:"expiration"`
26+
LastUse time.Time `json:"lastUse"`
27+
Creation time.Time `json:"creation"`
2228
}
2329

2430
func clientDefault(c *Config) (*ovh.Client, error) {
@@ -54,13 +60,13 @@ func (c *Config) loadAndValidate() error {
5460
return fmt.Errorf("Error getting ovh client: %q\n", err)
5561
}
5662

57-
var me PartialMe
58-
err = targetClient.Get("/me", &me)
63+
var cred OvhAuthCurrentCredential
64+
err = targetClient.Get("/auth/currentCredential", &cred)
5965
if err != nil {
6066
return fmt.Errorf("OVH client seems to be misconfigured: %q\n", err)
6167
}
6268

63-
log.Printf("[DEBUG] Logged in on OVH API as %s!", me.Firstname)
69+
log.Printf("[DEBUG] Logged in on OVH API")
6470
c.OVHClient = targetClient
6571

6672
return nil

0 commit comments

Comments
 (0)