-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathauth.go
54 lines (49 loc) · 1.29 KB
/
auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package gw2api
// Permission abstracts the bitmask containing permission information
type Permission uint
// Perm* represent the specific permission as required by the API
const (
_ = iota
PermAccount Permission = iota
PermCharacter
PermInventory
PermTradingpost
PermWallet
PermUnlocks
PermPvP
PermBuilds
PermProgression
PermGuilds
PermSize
)
//
var (
permissionsMapping = map[string]Permission{
"account": PermAccount,
"characters": PermCharacter,
"inventories": PermInventory,
"tradingpost": PermTradingpost,
"wallet": PermWallet,
"unlocks": PermUnlocks,
"pvp": PermPvP,
"builds": PermBuilds,
"progression": PermProgression,
"guilds": PermGuilds,
}
)
// TokenInfo contains information about the provided API Key of the user.
// Including the name of the key as set by the user and the permissions
// associated with it
type TokenInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Permissions []string `json:"permissions"`
}
// TokenInfo requests the token information from the authenticated API
// Requires authentication
func (gw2 *GW2Api) TokenInfo() (token TokenInfo, err error) {
ver := "v2"
tag := "tokeninfo"
err = gw2.fetchAuthenticatedEndpoint(ver, tag, 0, nil, &token)
return
}