### Start the Glipbot Auth Application Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral/cmd/glipbot_auth Run the glipbot_auth.go application using the go run command. This starts the HTTP server that handles Glip bot provisioning. ```bash go run glipbot_auth.go ``` -------------------------------- ### Navigate to Glipbot Auth Example Directory Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral/cmd/glipbot_auth Change your current directory to the glipbot_auth example within the cloned goauth repository. This is necessary to access the example's files. ```bash cd $GOPATH/src/github.com/grokify/goauth/ringcentral/examples/glipbot_auth ``` -------------------------------- ### Install GoAuth Source: https://pkg.go.dev/github.com/grokify/goauth Install the GoAuth library using the go get command. Requires Go 1.24+. ```bash go get github.com/grokify/goauth ``` -------------------------------- ### GoAuth JSON Configuration Example Source: https://pkg.go.dev/github.com/grokify/goauth Example of a JSON configuration file for GoAuth, demonstrating how to set up multiple credentials for different services and authentication types, including Google OAuth2, RingCentral password grant, and a custom API key. ```json { "credentials": { "my-google-app": { "service": "google", "type": "oauth2", "oauth2": { "clientID": "your-client-id", "clientSecret": "your-client-secret", "redirectURL": "https://example.com/callback", "scope": ["email", "profile"], "grantType": "authorization_code" } }, "my-ringcentral-app": { "service": "ringcentral", "type": "oauth2", "oauth2": { "clientID": "your-client-id", "clientSecret": "your-client-secret", "grantType": "password", "username": "your-username", "password": "your-password" } }, "my-api-key": { "type": "headerquery", "headerquery": { "serverURL": "https://api.example.com", "header": { "X-API-Key": "your-api-key" } } } } } ``` -------------------------------- ### Get OAuth2 Config from Wrapper Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Retrieves an oauth2.Config from an AppCredentialsWrapper. It attempts to use 'web' credentials first, then 'installed'. ```go func (w *AppCredentialsWrapper) Config() (*oauth2.Config, error) ``` -------------------------------- ### MockServer.ListenAndServe Source: https://pkg.go.dev/github.com/grokify/goauth/authutil/introspect%40v0.23.29 Starts the mock introspection server on the specified address. ```APIDOC ## MockServer.ListenAndServe ### Description Starts the mock introspection server on the specified address. ### Method Signature func (ms MockServer) ListenAndServe(addr string) error ### Parameters - **addr** (string) - The network address to listen on (e.g., ":8080"). ### Returns - **error** - An error if the server fails to start or run. ``` -------------------------------- ### Create Credentials from CLI (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Constructs `Credentials` from the command-line interface, optionally including accounts on error. Useful for interactive credential setup. ```go func NewCredentialsFromCLI(inclAccountsOnError bool) (Credentials, error) ``` -------------------------------- ### Get Keys from CredentialsSet Source: https://pkg.go.dev/github.com/grokify/goauth Returns a list of all keys (account names) available in the CredentialsSet. ```go func (set *CredentialsSet) Keys() []string ``` -------------------------------- ### MockServer NewServeMux Method Source: https://pkg.go.dev/github.com/grokify/goauth/authutil/introspect Creates and returns a new http.ServeMux for the mock server. This allows custom routing if needed before starting the server. ```go func (ms MockServer) NewServeMux() *http.ServeMux ``` -------------------------------- ### Get HTTP Client from Config File Store Source: https://pkg.go.dev/github.com/grokify/goauth/google Returns an `http.Client` configured with credentials and scopes managed by the `GoogleConfigFileStore`. Handles token acquisition if necessary. ```go func (gc *GoogleConfigFileStore) Client(ctx context.Context) (*http.Client, error) ``` -------------------------------- ### Get Credentials from Options Source: https://pkg.go.dev/github.com/grokify/goauth Retrieves credentials based on the parsed Options. This can involve reading from files or environment variables. ```go func (opts *Options) Credentials() (Credentials, error) ``` -------------------------------- ### Get O2ConfigMore or Panic Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Retrieves a specific OAuth2 configuration by its key. Panics if the key is not found. ```go func (cfgs *ConfigMoreSet) MustGet(key string) *O2ConfigMore ``` -------------------------------- ### Create HTTP Client from File and Key (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Initializes a new `http.Client` using credentials from a specified file and key. Requires a context, the path to the GoAuth file, and the key. ```go func NewClient(ctx context.Context, goauthfile, goauthkey string) (*http.Client, error) ``` -------------------------------- ### Create HTTP Client from Credentials File Source: https://pkg.go.dev/github.com/grokify/goauth Demonstrates creating an HTTP client using credentials loaded from a file. Requires a context and the path to the credentials file. ```go package main import ( "context" "github.com/grokify/goauth" ) func main() { ctx := context.Background() // From credentials file with account key client, err := goauth.NewClient(ctx, "credentials.json", "my-google-app") if err != nil { panic(err) } // Use client for API requests resp, err := client.Get("https://api.example.com/resource") } ``` -------------------------------- ### Initialize Zendesk ClientUtil Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk Creates a new instance of ClientUtil with the provided http.Client and subdomain. ```go func NewClientUtil(client *http.Client, subdomain string) ClientUtil ``` -------------------------------- ### Create Simple HTTP Client from Credentials (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Initializes a simple `httpsimple.Client` using the `Credentials`. This client is suitable for basic HTTP operations. ```go func (creds *Credentials) NewSimpleClient(ctx context.Context) (*httpsimple.Client, error) ``` -------------------------------- ### HTTP GET Request with Bearer Token Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request to a URL, including a Bearer token in the Authorization header. Returns the response. ```go func HTTPGetBearerToken(url, token string) (*http.Response, error) ``` -------------------------------- ### Initialize TokenStoreFile with Defaults Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Creates a TokenStoreFile, optionally using a default directory and setting file permissions. Useful for managing token storage location. ```go func NewTokenStoreFileDefault(tokenPath string, useDefaultDir bool, perm os.FileMode) (*TokenStoreFile, error) ``` -------------------------------- ### HTTP GET Request with Bearer Token and Response Body Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request to a URL with a Bearer token and returns both the response and its body. Useful for fetching data directly. ```go func HTTPGetBearerTokenBody(url, token string) (*http.Response, []byte, error) ``` -------------------------------- ### MockServer ListenAndServe Method Source: https://pkg.go.dev/github.com/grokify/goauth/authutil/introspect Starts the mock introspection server on a given network address. This method is blocking and will run until the server is stopped or encounters an error. ```go func (ms MockServer) ListenAndServe(addr string) error ``` -------------------------------- ### Initialize Metabase Client with Environment Variables Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Initializes a Metabase client using default environment variable names for configuration. Ensure METABASE_BASE_URL, METABASE_USERNAME, and METABASE_PASSWORD are set. ```go import ("github.com/grokify/goauth") httpClient, authResponse, clientConfig, err := metabase.NewClientEnv(nil) ``` -------------------------------- ### Create New ClientUtil Instance Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Initializes and returns a new ClientUtil instance. It requires the Metabase base URL, username, password, and a flag to skip TLS verification. ```go func NewClientUtil(baseURL, username, password string, tlsSkipVerify bool) (*ClientUtil, error) ``` -------------------------------- ### Create OAuth2 Client Utility by Provider String Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Use this function to get an OAuth2 utility instance by providing the provider type as a string. ```go func NewClientUtilForProviderTypeString(providerTypeString string) (authutil.OAuth2Util, error) ``` -------------------------------- ### Get Specific Credentials Source: https://pkg.go.dev/github.com/grokify/goauth Retrieves a specific credential by its key from the CredentialsSet. ```go func (set *CredentialsSet) Get(key string) (Credentials, error) ``` -------------------------------- ### Create HTTP Client with File Token Store Source: https://pkg.go.dev/github.com/grokify/goauth/google Initializes an HTTP client with Google credentials stored in a token file. Supports forcing new token generation and specifying a default directory. Requires context, credentials, scopes, token path, and other configuration options. ```go func NewClientFileStore( ctx context.Context, credentials []byte, scopes []string, tokenPath string, useDefaultDir bool, forceNewToken bool, state string) (*http.Client, error) ``` -------------------------------- ### NewClientEnv Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Initializes a Metabase client using environment variables for configuration. It returns an HTTP client, authentication response, and configuration object. ```APIDOC ## NewClientEnv ### Description Initializes a Metabase client using environment variables for configuration. It returns an HTTP client, authentication response, and configuration object. ### Function Signature ```go func NewClientEnv(opts *ConfigEnvOpts) (*http.Client, *AuthResponse, *Config, error) ``` ### Usage Example ```go httpClient, authResponse, clientConfig, err := metabase.NewClientEnv(nil) ``` ``` -------------------------------- ### Get OAuth2 Config Source: https://pkg.go.dev/github.com/grokify/goauth Retrieves the oauth2.Config object associated with the credentials. ```go func (oc *CredentialsOAuth2) Config() oauth2.Config ``` -------------------------------- ### Create HTTP Client with Basic Auth Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Initializes an http.Client with Basic Authentication credentials. Optionally skips TLS verification. ```go func NewClientBasicAuth(username, password string, tlsInsecureSkipVerify bool) (*http.Client, error) ``` -------------------------------- ### FirstRedirectURI Source: https://pkg.go.dev/github.com/grokify/goauth/google Gets the first redirect URI from the credentials. Added in v0.23.0. ```APIDOC ## FirstRedirectURI ### Description Gets the first redirect URI from the credentials. Added in v0.23.0. ### Method Signature ```go func (c Credentials) FirstRedirectURI() string ``` ``` -------------------------------- ### Get Store Question Data with File Mode Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Fetches Metabase question data and saves it to a file. Allows specifying the card ID, filename, and file mode for permissions. ```go func (cu *ClientUtil) GetStoreQuestionData(cardID int, filename string, perm os.FileMode) ([]byte, error) ``` -------------------------------- ### HTTPGetBearerTokenBody Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request and returns the response and its body. ```APIDOC ## func HTTPGetBearerTokenBody(url, token string) (*http.Response, []byte, error) ### Description Executes an HTTP GET request to a given URL with a Bearer token and returns both the HTTP response and the response body as a byte slice. This is useful when the response content needs to be processed directly. ### Parameters #### Path Parameters - **url** (string) - Required - The target URL for the GET request. - **token** (string) - Required - The Bearer token for authentication. ### Returns - (*http.Response) - The server's response to the request. - ([]byte) - The body of the response as a byte slice. - (error) - An error encountered during the request. ``` -------------------------------- ### Create Simple HTTP Client using Existing HTTP Client (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Creates a `httpsimple.Client` by wrapping an existing `http.Client`. Useful when you need to reuse an already configured HTTP client. ```go func (creds *Credentials) NewSimpleClientHTTP(httpClient *http.Client) (*httpsimple.Client, error) ``` -------------------------------- ### NewSalesforceClientEnv Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Initializes a new Salesforce client using environment variables for configuration. ```APIDOC ## func NewSalesforceClientEnv ### Description Initializes a new Salesforce client using environment variables for configuration. ### Signature ```go func NewSalesforceClientEnv() (SalesforceClient, error) ``` ### Returns - SalesforceClient - The initialized Salesforce client. - error - An error if initialization fails. ``` -------------------------------- ### HTTPGetBearerToken Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request with a Bearer token in the Authorization header. ```APIDOC ## HTTPGetBearerToken ### Description Performs an HTTP GET request with a Bearer token in the Authorization header. ### Function Signature ```go func HTTPGetBearerToken(url, token string) (*http.Response, error) ``` ``` -------------------------------- ### Google OAuth2 ClientUtil for SCIM User Source: https://pkg.go.dev/github.com/grokify/goauth Example of using Google's specific ClientUtil to retrieve canonical user information via SCIM. Requires an initialized OAuth2 HTTP client. ```go import "github.com/grokify/goauth/google" googleClientUtil := google.NewClientUtil(googleOAuth2HTTPClient) scimUser, err := googleClientUtil.GetSCIMUser() ``` -------------------------------- ### Clone the Goauth Repository Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral/cmd/glipbot_auth Clone the goauth repository to your local machine using the go get command. This command fetches the source code for the goauth project. ```bash go get github.com/grokify/goauth ``` -------------------------------- ### Get Credentials from Container Source: https://pkg.go.dev/github.com/grokify/goauth/google Retrieves the `Credentials` struct from a `CredentialsContainer`. Returns a pointer to the credentials. ```go func (cc *CredentialsContainer) Credentials() *Credentials ``` -------------------------------- ### Create HTTP Client from File Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an authenticated HTTP client using credentials from a file. Requires context, file path, scopes, and an optional token. ```go func ClientFromFile(ctx context.Context, filepath string, scopes []string, tok *oauth2.Token) (*http.Client, error) ``` -------------------------------- ### HTTPGetBearerTokenBody Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request with a Bearer token and returns the response body. ```APIDOC ## HTTPGetBearerTokenBody ### Description Performs an HTTP GET request with a Bearer token and returns the response body. ### Function Signature ```go func HTTPGetBearerTokenBody(url, token string) (*http.Response, []byte, error) ``` ``` -------------------------------- ### Create HTTP Client from Command-Line State (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Creates an `http.Client` based on the provided state string, typically used in command-line applications. Requires a context and the state. ```go func NewClientCmd(ctx context.Context, state string) (*http.Client, error) ``` -------------------------------- ### Create Credentials from Set File (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Loads `Credentials` from a specified file, using an account key for decryption or selection. Supports including accounts on error. ```go func NewCredentialsFromSetFile(credentialsSetFilename, accountKey string, inclAccountsOnError bool) (Credentials, error) ``` -------------------------------- ### Get Standard OAuth2 Config Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Converts the O2ConfigMore object into a standard oauth2.Config object. ```go func (cm *O2ConfigMore) Config() *oauth2.Config ``` -------------------------------- ### Initialize TokenStoreFile Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Creates a new TokenStoreFile instance associated with a specific file path. This prepares the store for reading or writing tokens. ```go func NewTokenStoreFile(file string) *TokenStoreFile ``` -------------------------------- ### Get Slugs from ConfigMoreSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Returns a slice of all configuration keys (slugs) present in the ConfigMoreSet. ```go func (cfgs *ConfigMoreSet) Slugs() []string ``` -------------------------------- ### Create HTTP Client for CLI from Credentials (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Creates an `http.Client` specifically for command-line interface usage, using the provided `Credentials` and OAuth2 state. Requires a context. ```go func (creds *Credentials) NewClientCLI(ctx context.Context, oauth2State string) (*http.Client, error) ``` -------------------------------- ### String Representation of AuthorizationType Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Returns the English name of an AuthorizationType. For example, 'Basic' for the Basic type. ```go func (a AuthorizationType) String() string ``` -------------------------------- ### Create HTTP Client from Credentials (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Generates an `http.Client` configured with the authentication details from the `Credentials` object. Requires a context. ```go func (creds *Credentials) NewClient(ctx context.Context) (*http.Client, error) ``` -------------------------------- ### Get Account Names from CredentialsSet Source: https://pkg.go.dev/github.com/grokify/goauth Returns a list of account names (keys) present in the CredentialsSet. ```go func (set *CredentialsSet) Accounts() []string ``` -------------------------------- ### Create Service Account HTTP Client from File Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an authenticated HTTP client using service account credentials from a specified file. Supports variadic scopes. ```go func NewClientSvcAccountFromFile(ctx context.Context, svcAccountConfigFile string, scopes ...string) (*http.Client, error) ``` -------------------------------- ### Get Client Credentials Config Source: https://pkg.go.dev/github.com/grokify/goauth Retrieves the clientcredentials.Config object for client credentials grant type. ```go func (oc *CredentialsOAuth2) ConfigClientCredentials() clientcredentials.Config ``` -------------------------------- ### Create and Edit .env File Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral/cmd/glipbot_auth Copy the sample environment file to .env and then edit it to configure your application settings. This file typically contains sensitive information like API keys and secrets. ```bash cp sample.env .env vi .env ``` -------------------------------- ### Get OAuth2 Endpoint (v0.23.0) Source: https://pkg.go.dev/github.com/grokify/goauth/google Returns the OAuth2 endpoint configuration for the credentials. Added in v0.23.0. ```go func (c Credentials) OAuth2Endpoint() oauth2.Endpoint ``` -------------------------------- ### NewClientFileStoreWithDefaults Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an http.Client with default settings using provided credentials and scopes. ```APIDOC ## func NewClientFileStoreWithDefaults(ctx context.Context, googleCredentials []byte, googleScopes []string, ...) (*http.Client, error) ### Description Constructs an http.Client with default configurations, utilizing provided Google credentials (as bytes) and a list of Google scopes. The ellipsis (...) suggests the possibility of further default configurations or options. ### Parameters #### Path Parameters - **googleCredentials** ([]byte) - Required - Google credentials in byte format. - **googleScopes** ([]string) - Required - A list of Google OAuth2 scopes. #### Query Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - (*http.Client) - A default-configured http.Client. - (error) - An error if the client cannot be created. ``` -------------------------------- ### HTTPGetBearerToken Source: https://pkg.go.dev/github.com/grokify/goauth/google Performs an HTTP GET request to a URL, including a Bearer token in the Authorization header. ```APIDOC ## func HTTPGetBearerToken(url, token string) (*http.Response, error) ### Description Sends an HTTP GET request to the specified URL with a Bearer token in the Authorization header. This is useful for accessing protected resources. ### Parameters #### Path Parameters - **url** (string) - Required - The URL to send the GET request to. - **token** (string) - Required - The Bearer token to include in the request. ### Returns - (*http.Response) - The HTTP response from the server. - (error) - An error if the request fails. ``` -------------------------------- ### Create HTTP Client with Web Token Store Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Initializes an http.Client using a web token store, allowing for token persistence and refresh. Can force a new token generation. ```go func NewClientWebTokenStore(ctx context.Context, conf *oauth2.Config, tStore *TokenStoreFile, forceNewToken bool, state string) (*http.Client, error) ``` -------------------------------- ### Get All Salesforce Contacts Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Retrieves all contacts from Salesforce. The returned value is a set of contacts that can be iterated over. ```go func (sc *SalesforceClient) GetContactsAll() (sobjects.ContactSet, error) ``` -------------------------------- ### Get All Salesforce Accounts Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Retrieves all accounts from Salesforce. The result is a set of accounts, which should be processed accordingly. ```go func (sc *SalesforceClient) GetAccountsAll() (sobjects.AccountSet, error) ``` -------------------------------- ### Create HTTP Client with Default File Token Store Source: https://pkg.go.dev/github.com/grokify/goauth/google Returns an HTTP client using a file system cache for access tokens. Simplifies token management by using defaults. Requires context, Google credentials, scopes, and a flag to force new token generation. ```go func NewClientFileStoreWithDefaults(ctx context.Context, googleCredentials []byte, googleScopes []string, forceNewToken bool) (*http.Client, error) ``` -------------------------------- ### NewClientFileStoreWithDefaultsCliEnv Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an http.Client using default settings from environment variables for credentials and scopes. ```APIDOC ## func NewClientFileStoreWithDefaultsCliEnv(ctx context.Context, googleCredentialsEnvVar, googleScopesEnvVar string) (*http.Client, error) ### Description Initializes an http.Client with default settings, reading Google credentials and scopes from specified environment variables. This function is convenient for deployment environments where configuration is managed via environment variables. ### Parameters #### Path Parameters - **googleCredentialsEnvVar** (string) - Required - The name of the environment variable holding Google credentials. - **googleScopesEnvVar** (string) - Required - The name of the environment variable holding Google scopes. #### Query Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - (*http.Client) - A default-configured http.Client. - (error) - An error if environment variables are missing or client creation fails. ``` -------------------------------- ### Get Lyft OAuth Endpoint Source: https://pkg.go.dev/github.com/grokify/goauth/lyft Retrieves the default OAuth 2.0 endpoint configuration for Lyft. ```go func Endpoint() oauth2.Endpoint ``` -------------------------------- ### Get Password Request Body Source: https://pkg.go.dev/github.com/grokify/goauth Returns the URL-encoded values for a password grant type request body. ```go func (oc *CredentialsOAuth2) PasswordRequestBody() url.Values ``` -------------------------------- ### NewClientFileStoreWithDefaultsCliEnv Source: https://pkg.go.dev/github.com/grokify/goauth/google Instantiates an `*http.Client` for the Google API for use from the command line interface (CLI). It will prompt the user to open the browser to auth when necessary. ```APIDOC ## NewClientFileStoreWithDefaultsCliEnv ### Description Instantiates an `*http.Client` for the Google API for use from the command line interface (CLI). It will prompt the user to open the browser to auth when necessary. ### Function Signature ```go func NewClientFileStoreWithDefaultsCliEnv(ctx context.Context, googleCredentialsEnvVar, googleScopesEnvVar string) (*http.Client, error) ``` ``` -------------------------------- ### Create a New ConfigMoreSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Initializes an empty ConfigMoreSet. ```go func NewConfigMoreSet() *ConfigMoreSet ``` -------------------------------- ### Get Client Credentials Token Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Obtains an OAuth2 token using the Client Credentials grant type. ```go func ClientCredentialsToken(ctx context.Context, cfg clientcredentials.Config) (*oauth2.Token, error) ``` -------------------------------- ### Get Specific O2ConfigMore from ConfigMoreSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Retrieves a specific OAuth2 configuration by its key. Returns an error if not found. ```go func (cfgs *ConfigMoreSet) Get(key string) (*O2ConfigMore, error) ``` -------------------------------- ### Load Credentials Set from File Source: https://pkg.go.dev/github.com/grokify/goauth Loads a set of credentials from a file and retrieves specific credentials by name. Also shows how to list all available accounts. ```go package main import ( "context" "github.com/grokify/goauth" ) func main() { ctx := context.Background() // Load credentials set from file set, err := goauth.ReadFileCredentialsSet("credentials.json", true) if err != nil { panic(err) } // Get specific credentials creds, err := set.Get("my-google-app") if err != nil { panic(err) } // Create client from credentials client, err := creds.NewClient(ctx) if err != nil { panic(err) } // List all account keys accounts := set.Accounts() } ``` -------------------------------- ### Get Client URLs Map from ConfigMoreSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Retrieves a map of client URLs from the configurations stored in ConfigMoreSet. ```go func (cfgs *ConfigMoreSet) ClientURLsMap() map[string]AppURLs ``` -------------------------------- ### Create New HTTP Client from Credentials (v0.20.0) Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates a new `http.Client` using the provided context, scopes, and credentials. Added in v0.20.0. ```go func (c Credentials) NewClient(ctx context.Context, scopes []string) (*http.Client, error) ``` -------------------------------- ### Get Columns Function Source: https://pkg.go.dev/github.com/grokify/goauth/hubspot A function that returns a slice of strings representing the column headers for contact data. ```go func Columns() []string ``` -------------------------------- ### AppCredentialsWrapper Struct Definition Source: https://pkg.go.dev/github.com/grokify/goauth/authutil A wrapper struct to hold different types of application credentials, such as 'web' and 'installed' applications. ```go type AppCredentialsWrapper struct { Web *AppCredentials `json:"web"` Installed *AppCredentials `json:"installed"` } ``` -------------------------------- ### Create HTTP Client from CredentialsSet Source: https://pkg.go.dev/github.com/grokify/goauth Creates an http.Client using credentials specified by a key from the CredentialsSet. ```go func (set *CredentialsSet) NewClient(ctx context.Context, key string) (*http.Client, error) ``` -------------------------------- ### Create HTTP Client from Config Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Creates an http.Client and authentication response based on the configuration stored in a Config struct. Handles authentication using session ID or username/password. ```go func (cfg *Config) NewClient() (*http.Client, *AuthResponse, error) ``` -------------------------------- ### Get First Redirect URI (v0.23.0) Source: https://pkg.go.dev/github.com/grokify/goauth/google Retrieves the first redirect URI from the Credentials struct. Added in v0.23.0. ```go func (c Credentials) FirstRedirectURI() string ``` -------------------------------- ### Create HTTP Client from Environment Variables Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral Creates an HTTP client by dynamically reading RingCentral configuration from environment variables prefixed with the provided string. ```go func NewHTTPClientEnvFlexStatic(envPrefix string) (*http.Client, error) ``` -------------------------------- ### Create HTTP Client with Header and Query Params Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Returns an http.Client that automatically adds specified headers and query parameters to every request. Can optionally allow insecure connections. ```go func NewClientHeaderQuery(header http.Header, query url.Values, allowInsecure bool) *http.Client ``` -------------------------------- ### Get Salesforce Services Data Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Fetches general services data from Salesforce. The response should be inspected for relevant information. ```go func (sc *SalesforceClient) GetServicesData() (*http.Response, error) ``` -------------------------------- ### Create HTTP Client with Token Source: https://pkg.go.dev/github.com/grokify/goauth Creates an http.Client configured with OAuth2 token. Returns the client and the token. ```go func (oc *CredentialsOAuth2) NewClient(ctx context.Context) (*http.Client, *oauth2.Token, error) ``` -------------------------------- ### Get Zendesk SCIM User Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk Retrieves SCIM user information using the ClientUtil. Requires appropriate permissions. ```go func (cu *ClientUtil) GetSCIMUser() (scim.User, error) ``` -------------------------------- ### Get User Credentials Directory Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Retrieves the default directory path for storing user credentials. This path is typically OS-dependent. ```go func UserCredentialsDir() (string, error) ``` -------------------------------- ### Create User Credentials Directory Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Creates the user credentials directory with specified file permissions. Use this to ensure the directory exists before writing credentials. ```go func UserCredentialsDirMk(perm os.FileMode) (string, error) ``` -------------------------------- ### User.EmailAddress Source: https://pkg.go.dev/github.com/grokify/goauth/scim Gets the primary email address or falls back to a non-primary one. Returns an empty string if no email is found. ```APIDOC ## User.EmailAddress ### Description Gets the primary email address or falls back to a non-primary one. Returns an empty string if no email is found. ### Method Signature ```go func (user *User) EmailAddress() string ``` ``` -------------------------------- ### Create CLI HTTP Client with Environment Variables Source: https://pkg.go.dev/github.com/grokify/goauth/google Instantiates an HTTP client for Google API CLI applications. It reads credentials and scopes from environment variables and prompts the user for authentication if necessary. ```go func NewClientFileStoreWithDefaultsCliEnv(ctx context.Context, googleCredentialsEnvVar, googleScopesEnvVar string) (*http.Client, error) ``` -------------------------------- ### OAuth 2.0 Token Endpoint Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce This example shows how to obtain an OAuth 2.0 token for Salesforce using the password grant type. ```APIDOC ## POST /services/oauth2/token ### Description Obtains an OAuth 2.0 token for Salesforce using the password grant type. ### Method POST ### Endpoint https://login.salesforce.com/services/oauth2/token ### Parameters #### Request Body - **grant_type** (string) - Required - Specifies the grant type, e.g., "password". - **client_id** (string) - Required - Your Salesforce connected app's client ID. - **client_secret** (string) - Required - Your Salesforce connected app's client secret. - **username** (string) - Required - Your Salesforce username. - **password** (string) - Required - Your Salesforce password followed by your security token. ### Request Example ```bash curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=myClientID" -d "client_secret=myClientSecret" -d "username=myUsername" -d "password=myPasswordMySecretToken" ``` ``` -------------------------------- ### New Salesforce Client with Password Credentials Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Initializes a new Salesforce client using OAuth2 credentials and an instance name. Ensure that the OAuth2Credentials struct is properly populated. ```go func NewSalesforceClientPassword(soc OAuth2Credentials) (SalesforceClient, error) ``` -------------------------------- ### Get Basic Auth Header Source: https://pkg.go.dev/github.com/grokify/goauth Returns the Basic Authentication header string. This is typically used for client credentials grant type. ```go func (oc *CredentialsOAuth2) BasicAuthHeader() (string, error) ``` -------------------------------- ### Get OAuth2 Configuration from Container Source: https://pkg.go.dev/github.com/grokify/goauth/google Generates an `oauth2.Config` object from the `CredentialsContainer` for a given set of scopes. Returns an error if configuration fails. ```go func (cc *CredentialsContainer) OAuth2Config(scopes ...string) (*oauth2.Config, error) ``` -------------------------------- ### NewClientEnv Source: https://pkg.go.dev/github.com/grokify/goauth/visa Creates a new HTTP client using environment variables for configuration. ```APIDOC ## func NewClientEnv() ### Description Creates a new HTTP client using environment variables for configuration. The following environment variables are used: `VISA_APP_KEY_FILE`, `VISA_APP_CERT_FILE`, `VISA_APP_USERID`, `VISA_APP_PASSWORD`, `VISA_VDP_CA_CERT_FILE`, `VISA_GEOTRUST_CA_CERT_FILE`. ### Method Go function call ### Signature ```go func NewClientEnv() (*http.Client, error) ``` ``` -------------------------------- ### NewClientFileStoreWithDefaults Source: https://pkg.go.dev/github.com/grokify/goauth/google Returns a `*http.Client` using file system cache for access tokens. ```APIDOC ## NewClientFileStoreWithDefaults ### Description Returns a `*http.Client` using file system cache for access tokens. ### Function Signature ```go func NewClientFileStoreWithDefaults(ctx context.Context, googleCredentials []byte, googleScopes []string, forceNewToken bool) (*http.Client, error) ``` ``` -------------------------------- ### Get Salesforce User Info Source: https://pkg.go.dev/github.com/grokify/goauth/salesforce Retrieves information about the currently authenticated user. This is useful for verifying authentication and obtaining user-specific details. ```go func (sc *SalesforceClient) UserInfo() (User, error) ``` -------------------------------- ### Project Version and Path Constants Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Constants defining the project's version and import path. ```go const ( VERSION = "0.10" PATH = "github.com/grokify/goauth" ) ``` -------------------------------- ### Create Zendesk HTTP Client with Password Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk Creates an http.Client for Zendesk API requests using basic authentication with email and password. Ensure your credentials are valid. ```go func NewClientPassword(ctx context.Context, emailAddress, password string) (*http.Client, error) ``` -------------------------------- ### Get API Version Path Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Retrieves the API version path. This function likely returns a string representing the current API version. ```go func PathVersion() string ``` -------------------------------- ### Create Credentials Container from File Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates a `CredentialsContainer` by reading from a specified file path. Handles file I/O and deserialization. ```go func CredentialsContainerFromFile(file string) (CredentialsContainer, error) ``` -------------------------------- ### Get Zendesk User Info Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk Retrieves the current user's information using the ClientUtil. This method fetches data from the 'Me' endpoint. ```go func (cu *ClientUtil) GetUserinfo() (*Me, error) ``` -------------------------------- ### Create HTTP Client with Token Type and Value Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Initializes an http.Client with a specified token type and value. Can optionally allow insecure connections. ```go func NewClientToken(tokenType, tokenValue string, allowInsecure bool) *http.Client ``` -------------------------------- ### Create OAuth2 Client Utility by Provider Type Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Use this function to get an OAuth2 utility instance based on a predefined provider type. ```go func NewClientUtilForProviderType(providerType OAuth2Provider) (authutil.OAuth2Util, error) ``` -------------------------------- ### Create Credentials from JSON Data (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Initializes `Credentials` from provided JSON data and an access token. Useful for loading credentials from configuration files or API responses. ```go func NewCredentialsFromJSON(credsData, accessToken []byte) (Credentials, error) ``` -------------------------------- ### Get Token Information from Redis Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice/tokens/tokensetredis Fetches detailed token information from Redis based on a key. Use this to retrieve metadata associated with a token. ```go func (toks *TokenSet) GetTokenInfo(ctx context.Context, key string) (*tokens.TokenInfo, error) ``` -------------------------------- ### New Facebook ClientUtil Constructor Source: https://pkg.go.dev/github.com/grokify/goauth/facebook Creates a new instance of ClientUtil with the provided http.Client. ```go func NewClientUtil(client *http.Client) ClientUtil ``` -------------------------------- ### Get OAuth2 Token from Redis Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice/tokens/tokensetredis Retrieves an OAuth2 token from Redis using a specified key. This function is essential for accessing stored tokens. ```go func (toks *TokenSet) GetToken(ctx context.Context, key string) (*oauth2.Token, error) ``` -------------------------------- ### NewClientUtil Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Initializes a new ClientUtil instance, which provides utility methods for interacting with the Metabase API. ```APIDOC ## NewClientUtil ### Description Initializes a new ClientUtil instance, which provides utility methods for interacting with the Metabase API. ### Function Signature ```go func NewClientUtil(baseURL, username, password string, tlsSkipVerify bool) (*ClientUtil, error) ``` ### Parameters - **baseURL** (string): The base URL of the Metabase instance. - **username** (string): The username for authentication. - **password** (string): The password for authentication. - **tlsSkipVerify** (bool): Whether to skip TLS verification. ### Returns - **(*ClientUtil, error)**: A pointer to a ClientUtil instance and any error encountered during initialization. ``` -------------------------------- ### Create Simple HTTP Client Source: https://pkg.go.dev/github.com/grokify/goauth Creates a simple http.Client for making requests. This client is often used for simpler API interactions. ```go func (oc *CredentialsOAuth2) NewSimpleClient(ctx context.Context) (*httpsimple.Client, error) ``` -------------------------------- ### SCIM UserSet Count Method Source: https://pkg.go.dev/github.com/grokify/goauth/scim Returns the total number of users currently in the UserSet. Provides a quick way to get the size of the user collection. ```go func (set *UserSet) Count() int ``` -------------------------------- ### Create ConfigMoreSet from Environment Variables Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Loads OAuth2 configurations from environment variables. Expects variables in AppCredentialsWrapper format. ```go func EnvOAuth2ConfigMap(env []osutil.EnvVar, prefix string) (*ConfigMoreSet, error) ``` -------------------------------- ### ClientFromFile Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an http.Client using credentials from a file, with specified scopes and an optional token. ```APIDOC ## func ClientFromFile(ctx context.Context, filepath string, scopes []string, tok *oauth2.Token) (*http.Client, error) ### Description Creates an http.Client using credentials from a file. It allows specifying the context, the path to the credentials file, a list of OAuth2 scopes, and an optional pre-existing token. ### Parameters #### Path Parameters - **filepath** (string) - Required - The path to the credentials file. #### Query Parameters - **ctx** (context.Context) - Required - The context for the request. - **scopes** ([]string) - Required - A list of OAuth2 scopes. - **tok** (*oauth2.Token) - Optional - An existing oauth2.Token. ### Returns - (*http.Client) - An authenticated http.Client. - (error) - An error if the client creation fails. ``` -------------------------------- ### Get Current User Information Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Retrieves information about the currently authenticated user from Metabase. Returns the user object, the HTTP response, and any error encountered. ```go func (cu *ClientUtil) GetCurrentUser() (User, *http.Response, error) ``` -------------------------------- ### Create HTTP Client with OAuth2 Token Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Returns an http.Client pre-configured with an oauth2.Token object. ```go func NewClientTokenOAuth2(token *oauth2.Token) *http.Client ``` -------------------------------- ### ClientOAuthCLITokenStoreConfig Struct Source: https://pkg.go.dev/github.com/grokify/goauth/google Configuration struct for creating an HTTP client with OAuth CLI token store. Includes context, app configuration, scopes, token file path, and force new token flag. ```go type ClientOAuthCLITokenStoreConfig struct { Context context.Context AppConfig []byte Scopes []string TokenFile string ForceNewToken bool State string } ``` -------------------------------- ### Get OAuth2 Token via CLI Web Flow Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Enables a CLI application to obtain an OAuth2 authorization code by having the user copy-paste a URL into a browser. ```go func NewTokenCLIFromWeb(ctx context.Context, cfg *oauth2.Config, state string) (*oauth2.Token, error) ``` -------------------------------- ### Get User Information from Facebook API Source: https://pkg.go.dev/github.com/grokify/goauth/ringcentral Retrieves user information from the Facebook API's userinfo endpoint. Requires a configured http.Client within the ClientUtil. ```go func (cu *ClientUtil) GetUserinfo() (RingCentralExtensionInfo, error) ``` -------------------------------- ### Create New Token via CLI from Web Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Initiates a new token acquisition flow suitable for command-line applications, using a web-based OAuth2 configuration. Requires context, config, and state parameter. ```go func (ts *TokenStoreFile) NewTokenCLIFromWeb(ctx context.Context, cfg *oauth2.Config, state string) (*oauth2.Token, error) ``` -------------------------------- ### Get Question Data by Card ID Source: https://pkg.go.dev/github.com/grokify/goauth/metabase Fetches the data for a Metabase question identified by its card ID. Returns the data as a byte slice and any error encountered. ```go func (cu *ClientUtil) GetQuestionData(cardID int) ([]byte, error) ``` -------------------------------- ### NewClientUtil Source: https://pkg.go.dev/github.com/grokify/goauth/facebook Creates a new instance of ClientUtil. ```APIDOC ## NewClientUtil ### Description Initializes a new ClientUtil with the provided HTTP client. ### Method (Constructor) ### Parameters #### Path Parameters - **client** (*http.Client) - Required - The HTTP client to use for API requests. ``` -------------------------------- ### Get Zendesk Me User Details Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk Fetches the current authenticated user's details from Zendesk. Returns the user object, the HTTP response, and any error encountered. ```go func GetMe(client *http.Client, subdomain string) (*Me, *http.Response, error) ``` -------------------------------- ### Department String Method Signature Source: https://pkg.go.dev/github.com/grokify/goauth/util/titles Provides the method signature for the String() method on the Department type. This method is used to get the string representation of a Department value. ```go func (d Department) String() string ``` -------------------------------- ### Create HTTP Client with Base64 Encoded Token Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Initializes an http.Client with a Base64 encoded token. Can optionally allow insecure connections. ```go func NewClientTokenBase64Encode(tokenType, tokenValue string, allowInsecure bool) *http.Client ``` -------------------------------- ### ClientUtil.NewClientUtil Source: https://pkg.go.dev/github.com/grokify/goauth/zendesk NewClientUtil creates a new ClientUtil. ```APIDOC ## NewClientUtil ### Description Creates a new ClientUtil. ### Signature ```go func NewClientUtil(client *http.Client, subdomain string) ClientUtil ``` ### Parameters #### Path Parameters - **client** (*http.Client) - Required - An authenticated http.Client. - **subdomain** (string) - Required - The Zendesk subdomain. ``` -------------------------------- ### Get New or Existing Valid Token (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Attempts to retrieve an existing valid token, or creates a new one if necessary, using the `Credentials`. Requires a context. ```go func (creds *Credentials) NewOrExistingValidToken(ctx context.Context) (*oauth2.Token, error) ``` -------------------------------- ### Create HTTP Client with TLS Token Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Returns an http.Client configured with TLS settings and an OAuth2 token. ```go func NewClientTLSToken(ctx context.Context, tlsConfig *tls.Config, token *oauth2.Token) *http.Client ``` -------------------------------- ### Get Existing Valid Token from Credentials (Go) Source: https://pkg.go.dev/github.com/grokify/goauth Retrieves an already existing and valid OAuth2 token from the `Credentials` object. Returns an error if no valid token is found. ```go func (creds *Credentials) ExistingValidToken() (*oauth2.Token, error) ``` -------------------------------- ### NewSimpleClient for CredentialsHeaderQuery Source: https://pkg.go.dev/github.com/grokify/goauth Creates a new httpsimple.Client using header and query parameters for authentication. ```go func (c *CredentialsHeaderQuery) NewSimpleClient() httpsimple.Client ``` -------------------------------- ### Get Account Credentials Token (Zoom) Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Obtains an OAuth2 token using the Account Credentials grant type, specifically designed for Zoom's S2S OAuth. ```go func NewTokenAccountCredentials(ctx context.Context, tokenEndpoint, clientID, clientSecret string, bodyOpts url.Values) (*oauth2.Token, error) ``` -------------------------------- ### NewClientOAuthCLITokenStore Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an http.Client using OAuth CLI token store configuration. ```APIDOC ## func NewClientOAuthCLITokenStore(cfg ClientOAuthCLITokenStoreConfig) (*http.Client, error) ### Description Initializes an http.Client configured with OAuth CLI token store settings. This method uses a provided configuration struct to manage token storage and retrieval for CLI applications. ### Parameters #### Path Parameters - **cfg** (ClientOAuthCLITokenStoreConfig) - Required - The configuration for the OAuth CLI token store. ### Returns - (*http.Client) - A configured http.Client. - (error) - An error if the client setup fails. ``` -------------------------------- ### Get Aha User Information Source: https://pkg.go.dev/github.com/grokify/goauth/aha Retrieves user information from the Aha API using the ClientUtil. Note: The description mentions Facebook API, which might be a documentation error. ```go func (apiutil *ClientUtil) GetUserinfo() (*AhaUserinfo, error) ``` -------------------------------- ### Create Simple HubSpot Client with API Key Source: https://pkg.go.dev/github.com/grokify/goauth/hubspot Creates a simple HubSpot client using an API key, suitable for basic operations. ```go func NewSimpleClientAPIKey(apiKey string) httpsimple.Client ``` -------------------------------- ### Create New OAuth Endpoint Source: https://pkg.go.dev/github.com/grokify/goauth/endpoints Use NewEndpoint to get an oauth2.Endpoint and API server URL from a service name and subdomain. Ensure the service name and subdomain are valid. ```go func NewEndpoint(serviceName, subdomain string) (oauth2.Endpoint, string, error) ``` -------------------------------- ### NewClientFileStore Source: https://pkg.go.dev/github.com/grokify/goauth/google Returns a `*http.Client` with Google credentials in a token store file. It will use the token file credentials unless `forceNewToken` is set to true. ```APIDOC ## NewClientFileStore ### Description Returns a `*http.Client` with Google credentials in a token store file. It will use the token file credentials unless `forceNewToken` is set to true. ### Function Signature ```go func NewClientFileStore( ctx context.Context, credentials []byte, scopes []string, tokenPath string, useDefaultDir bool, forceNewToken bool, state string) (*http.Client, error) ``` ``` -------------------------------- ### NewSimpleClient for CredentialsBasicAuth Source: https://pkg.go.dev/github.com/grokify/goauth Creates a new httpsimple.Client using basic authentication credentials. ```go func (c *CredentialsBasicAuth) NewSimpleClient() (httpsimple.Client, error) ``` -------------------------------- ### Parse Command-Line Options Source: https://pkg.go.dev/github.com/grokify/goauth Parses command-line options to configure credentials and token settings. Returns an Options struct or an error. ```go func ParseOptions() (*Options, error) ``` -------------------------------- ### RingCentral OAuth2 ClientUtil for SCIM User Source: https://pkg.go.dev/github.com/grokify/goauth Example of using RingCentral's specific ClientUtil to retrieve canonical user information via SCIM. Requires an initialized OAuth2 HTTP client. ```go import "github.com/grokify/goauth/ringcentral" rcClientUtil := ringcentral.NewClientUtil(rcOAuth2HTTPClient) scimUser, err := rcClientUtil.GetSCIMUser() ``` -------------------------------- ### NewClientSvcAccountFromFile Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an http.Client from a service account configuration file. ```APIDOC ## func NewClientSvcAccountFromFile(ctx context.Context, svcAccountConfigFile string, scopes ...string) (*http.Client, error) ### Description Generates an http.Client by loading service account credentials from a specified file. It supports multiple scopes and uses the provided context for the operation. ### Parameters #### Path Parameters - **svcAccountConfigFile** (string) - Required - The path to the service account configuration file. - **scopes** (...string) - Required - A variable number of OAuth2 scopes. #### Query Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - (*http.Client) - An authenticated http.Client. - (error) - An error if reading the file or creating the client fails. ``` -------------------------------- ### Facebook OAuth2 ClientUtil for SCIM User Source: https://pkg.go.dev/github.com/grokify/goauth Example of using Facebook's specific ClientUtil to retrieve canonical user information via SCIM. Requires an initialized OAuth2 HTTP client. ```go import "github.com/grokify/goauth/facebook" fbClientUtil := facebook.NewClientUtil(fbOAuth2HTTPClient) scimUser, err := fbClientUtil.GetSCIMUser() ``` -------------------------------- ### Options.NewClient Source: https://pkg.go.dev/github.com/grokify/goauth Creates a new HTTP client with the given context and state. Useful for making authenticated requests. ```APIDOC ## Options.NewClient ### Description Creates a new HTTP client with the given context and state. Useful for making authenticated requests. ### Signature ```go func (opts *Options) NewClient(ctx context.Context, state string) (*http.Client, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Client** (*http.Client) - An initialized http.Client. - **error** (error) - An error if the client creation fails. #### Response Example None ``` -------------------------------- ### NewConfigMoreSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice Initializes a new ConfigMoreSet. ```APIDOC ## NewConfigMoreSet ### Description Initializes a new ConfigMoreSet. ### Function Signature ```go func NewConfigMoreSet() *ConfigMoreSet ``` ``` -------------------------------- ### Get Client Credentials Token Source: https://pkg.go.dev/github.com/grokify/goauth/authutil Obtains an OAuth2 token using the client credentials grant type. This is an alternative to the standard `clientcredentials.Config.Token()` method, addressing potential encoding issues with request bodies. ```go func TokenClientCredentials(cfg clientcredentials.Config) (*oauth2.Token, error) ``` -------------------------------- ### ClientFromFile Source: https://pkg.go.dev/github.com/grokify/goauth/google Creates an HTTP client from a file, using provided scopes and an optional token. ```APIDOC ## ClientFromFile ### Description Creates an HTTP client from a file, using provided scopes and an optional token. ### Function Signature ```go func ClientFromFile(ctx context.Context, filepath string, scopes []string, tok *oauth2.Token) (*http.Client, error) ``` ``` -------------------------------- ### NewClient for CredentialsBasicAuth Source: https://pkg.go.dev/github.com/grokify/goauth Creates a new http.Client using basic authentication credentials. ```go func (c *CredentialsBasicAuth) NewClient() (*http.Client, error) ``` -------------------------------- ### Create New TokenSet Source: https://pkg.go.dev/github.com/grokify/goauth/multiservice/tokens/tokensetredis Initializes a new TokenSet instance with a provided Redis client. This is used to set up the token management system. ```go func NewTokenSet(client *redis.Client) *TokenSet ``` -------------------------------- ### Credentials.NewSimpleClient Source: https://pkg.go.dev/github.com/grokify/goauth Creates a new simple HTTP client from credentials. ```APIDOC ## Credentials.NewSimpleClient ### Description Creates a new `httpsimple.Client` using the credentials. ### Method Signature `func (creds *Credentials) NewSimpleClient(ctx context.Context) (*httpsimple.Client, error)` ### Parameters - **ctx** (context.Context) - The context for the request. ### Returns - `*httpsimple.Client` - An initialized simple HTTP client. - `error` - An error if client creation fails. ```