mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
28 lines
642 B
Go
28 lines
642 B
Go
package flows
|
|
|
|
import (
|
|
opaal "davidallendj/opaal/internal"
|
|
"fmt"
|
|
)
|
|
|
|
func Login(config *opaal.Config) error {
|
|
if config == nil {
|
|
return fmt.Errorf("config is not valid")
|
|
}
|
|
|
|
// initialize client that will be used throughout login flow
|
|
server := opaal.NewServerWithConfig(config)
|
|
client := opaal.NewClientWithConfig(config)
|
|
|
|
fmt.Printf("grant type: %v\n", config.GrantType)
|
|
|
|
if config.GrantType == "authorization_code" {
|
|
AuthorizationCode(config, server, client)
|
|
} else if config.GrantType == "client_credentials" {
|
|
ClientCredentials(config, server, client)
|
|
} else {
|
|
return fmt.Errorf("invalid grant type")
|
|
}
|
|
|
|
return nil
|
|
}
|