ParseScopeHeader parses the X-OAuth-Scopes header value into a list of scopes. The header contains comma-separated scope names. Returns an empty slice for empty or missing header.
(header string)
| 104 | // The header contains comma-separated scope names. |
| 105 | // Returns an empty slice for empty or missing header. |
| 106 | func ParseScopeHeader(header string) []string { |
| 107 | if header == "" { |
| 108 | return []string{} |
| 109 | } |
| 110 | |
| 111 | parts := strings.Split(header, ",") |
| 112 | scopes := make([]string, 0, len(parts)) |
| 113 | for _, part := range parts { |
| 114 | scope := strings.TrimSpace(part) |
| 115 | if scope != "" { |
| 116 | scopes = append(scopes, scope) |
| 117 | } |
| 118 | } |
| 119 | return scopes |
| 120 | } |
| 121 | |
| 122 | // FetchTokenScopes is a convenience function that creates a default fetcher |
| 123 | // and fetches the token scopes. |
no outgoing calls