authorizer package - github.com/authorizerdev/authorizer-go - Go Packages

Package authorizer provides client and methods using which you can perform various graphql operations to your authorizer instance

View Source

const (
	
	GrantTypeAuthorizationCode = "authorization_code"

	
	GrantTypeRefreshToken = "refresh_token"

	
	UserFragment = `` 

)

View Source

var AuthTokenResponseFragment = fmt.Sprintf(`message access_token expires_in refresh_token id_token should_show_email_otp_screen should_show_mobile_otp_screen should_show_totp_screen authenticator_scanner_image authenticator_secret authenticator_recovery_codes user { 	%s }`, UserFragment)

AuthTokenResponseFragment defines graphql response for auth token type, which is common across various authorizer operations

EncodeB64 returns string which is base64 encoded

NewStringRef returns a reference to a string with given value

StringValue returns the value of the given string ref

type AuthTokenResponse struct {
	Message                    *string   `json:"message,omitempty"`
	AccessToken                *string   `json:"access_token,omitempty"`
	ExpiresIn                  *int64    `json:"expires_in,omitempty"`
	IdToken                    *string   `json:"id_token,omitempty"`
	RefreshToken               *string   `json:"refresh_token,omitempty"`
	ShouldShowEmailOtpScreen   *bool     `json:"should_show_email_otp_screen"`
	ShouldShowMobileOtpScreen  *bool     `json:"should_show_mobile_otp_screen"`
	ShouldShowTotpScreen       *bool     `json:"should_show_totp_screen"`
	AuthenticatorScannerImage  *string   `json:"authenticator_scanner_image"`
	AuthenticatorSecret        *string   `json:"authenticator_secret"`
	AuthenticatorRecoveryCodes []*string `json:"authenticator_recovery_codes"`
	User                       *User     `json:"user,omitempty"`
}

AuthTokenResponse defines attribute for auth token response, which is common across various authorizer operations

AuthorizerClient defines the attributes required to initiate authorizer client

NewAuthorizerClient creates an authorizer client instance. It returns reference to authorizer client instance or error.

DeactivateAccount is method attached to AuthorizerClient. It performs deactivate_account mutation on authorizer instance. It returns Response reference or error. For implementation details check DeactivateAccountExample examples/deactivate_account.go

ForgotPassword is method attached to AuthorizerClient. It performs forgot_password mutation on authorizer instance. It takes ForgotPasswordRequest reference as parameter and returns ForgotPasswordResponse reference or error.

GetMetaData is method attached to AuthorizerClient. It performs meta query on authorizer instance. It returns MetaResponse reference or error.

GetProfile is method attached to AuthorizerClient. It performs profile query on authorizer instance. It returns User reference or error. For implementation details check GetProfileExample examples/get_profile.go

GetSession is method attached to AuthorizerClient. It performs session query on authorizer instance. It returns AuthTokenResponse reference or error.

GetToken is method attached to AuthorizerClient. It performs `/oauth/token` query on authorizer instance. It returns TokenResponse reference or error.

Login is method attached to AuthorizerClient. It performs login mutation on authorizer instance. It takes LoginRequest reference as parameter and returns AuthTokenResponse reference or error.

Logout is method attached to AuthorizerClient. It performs Logout mutation on authorizer instance. It takes LogoutInput reference as parameter and returns Response reference or error. For implementation details check LogoutExample examples/Logout.go

MagicLinkLogin is method attached to AuthorizerClient. It performs magic_link_login mutation on authorizer instance. It takes MagicLinkLoginRequest reference as parameter and returns Response reference or error.

ResendOTP is method attached to AuthorizerClient. It performs resend_otp mutation on authorizer instance. It takes ResendOTPRequest reference as parameter and returns Response reference or error.

ResendVerifyEmail is method attached to AuthorizerClient. It performs resend_verify_email mutation on authorizer instance. It takes ResendVerifyEmailRequest reference as parameter and returns Response reference or error.

ResetPassword is method attached to AuthorizerClient. It performs reset_password mutation on authorizer instance. It takes ResetPasswordRequest reference as parameter and returns Response reference or error.

RevokeToken is method attached to AuthorizerClient. It performs /oauth/revoke api call on authorizer instance. It takes RevokeTokenInput reference as parameter and returns Response reference or error.

SignUp is method attached to AuthorizerClient. It performs signup mutation on authorizer instance. It takes SignUpRequest reference as parameter and returns AuthTokenResponse reference or error.

UpdateProfile is method attached to AuthorizerClient. It performs update_profile mutation on authorizer instance. It returns Response reference or error.

ValidateJWTToken is method attached to AuthorizerClient. It performs validate_jwt_token query on authorizer instance. It returns ValidateJWTTokenResponse reference or error.

ValidateSession is method attached to AuthorizerClient. It performs validate_session query on authorizer instance. It returns ValidateSessionResponse reference or error.

VerifyEmail is method attached to AuthorizerClient. It performs verify_email mutation on authorizer instance. It returns AuthTokenResponse reference or error.

VerifyOTP is method attached to AuthorizerClient. It performs verify_otp mutation on authorizer instance. It returns AuthTokenResponse reference or error.

type ForgotPasswordInput = ForgotPasswordRequest

ForgotPasswordInput is deprecated: Use ForgotPasswordRequest instead

type ForgotPasswordRequest struct {
	Email       *string `json:"email,omitempty"`
	PhoneNumber *string `json:"phone_number,omitempty"`
	State       *string `json:"state,omitempty"`
	RedirectURI *string `json:"redirect_uri,omitempty"`
}

ForgotPasswordRequest defines attributes for forgot_password request

type ForgotPasswordResponse struct {
	Message                   string `json:"message"`
	ShouldShowMobileOtpScreen *bool  `json:"should_show_mobile_otp_screen"`
}

ForgotPasswordResponse defines attribute for forgot_password response

type GetTokenRequest struct {
	Code         *string `json:"code"`
	GrantType    *string `json:"grant_type"`
	RefreshToken *string `json:"refresh_token"`
}

GetTokenRequest defines attributes for token request

type GraphQLError struct {
	Message string   `json:"message"`
	Path    []string `json:"path"`
}
type GraphQLRequest struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables,omitempty"`
}

GraphQLRequest is object used to make graphql queries

type GraphQLResponse struct {
	Errors []*GraphQLError `json:"errors"`
	Data   interface{}     `json:"data"`
}
type LoginInput = LoginRequest

LoginInput is deprecated: Use LoginRequest instead

type LoginRequest struct {
	Email       *string   `json:"email,omitempty"`
	PhoneNumber *string   `json:"phone_number,omitempty"`
	Password    string    `json:"password"`
	Roles       []*string `json:"roles,omitempty"`
	Scope       []*string `json:"scope,omitempty"`
	State       *string   `json:"state,omitempty"`
}

LoginRequest defines attributes for login request

type MagicLinkLoginInput = MagicLinkLoginRequest

MagicLinkLoginInput is deprecated: Use MagicLinkLoginRequest instead

type MagicLinkLoginRequest struct {
	Email       string    `json:"email"`
	Roles       []*string `json:"roles,omitempty"`
	Scope       []*string `json:"scope,omitempty"`
	State       *string   `json:"state"`
	RedirectURI *string   `json:"redirect_uri"`
}

MagicLinkLoginRequest defines attributes for magic link login request

type MetaDataResponse struct {
	Version                            string `json:"version"`
	ClientID                           string `json:"client_id"`
	IsGoogleLoginEnabled               bool   `json:"is_google_login_enabled"`
	IsFacebookLoginEnabled             bool   `json:"is_facebook_login_enabled"`
	IsGithubLoginEnabled               bool   `json:"is_github_login_enabled"`
	IsLinkedinLoginEnabled             bool   `json:"is_linkedin_login_enabled"`
	IsAppleLoginEnabled                bool   `json:"is_apple_login_enabled"`
	IsTwitterLoginEnabled              bool   `json:"is_twitter_login_enabled"`
	IsDiscordLoginEnabled              bool   `json:"is_discord_login_enabled"`
	IsMicrosoftLoginEnabled            bool   `json:"is_microsoft_login_enabled"`
	IsTwitchLoginEnabled               bool   `json:"is_twitch_login_enabled"`
	IsRobloxLoginEnabled               bool   `json:"is_roblox_login_enabled"`
	IsEmailVerificationEnabled         bool   `json:"is_email_verification_enabled"`
	IsBasicAuthenticationEnabled       bool   `json:"is_basic_authentication_enabled"`
	IsMagicLinkLoginEnabled            bool   `json:"is_magic_link_login_enabled"`
	IsSignUpEnabled                    bool   `json:"is_sign_up_enabled"`
	IsStrongPasswordEnabled            bool   `json:"is_strong_password_enabled"`
	IsMultiFactorAuthEnabled           bool   `json:"is_multi_factor_auth_enabled"`
	IsMobileBasicAuthenticationEnabled bool   `json:"is_mobile_basic_authentication_enabled"`
	IsPhoneVerificationEnabled         bool   `json:"is_phone_verification_enabled"`
}

MetaDataResponse defines attributes for MetaData response query

type ResendOTPInput = ResendOTPRequest

ResendOTPInput is deprecated: Use ResendOTPRequest instead

type ResendOTPRequest struct {
	Email       *string `json:"email"`
	PhoneNumber *string `json:"phone_number"`
	State       *string `json:"state,omitempty"`
}

ResendOTPRequest defines attributes for resend_otp request

type ResendVerifyEmailRequest struct {
	Email      string  `json:"email"`
	Identifier *string `json:"identifier,omitempty"`
}

ResendVerifyEmailRequest defines attributes for resend_verify_email request

type ResetPasswordInput = ResetPasswordRequest

ResetPasswordInput is deprecated: Use ResetPasswordRequest instead

type ResetPasswordRequest struct {
	Token           *string `json:"token,omitempty"`
	Password        string  `json:"password"`
	ConfirmPassword string  `json:"confirm_password"`
	OTP             *string `json:"otp,omitempty"`
	PhoneNumber     *string `json:"phone_number,omitempty"`
}

ResetPasswordRequest defines attributes for reset_password request

type Response struct {
	Message string `json:"message"`
}

Response defines attribute for Response graphql type it is common across various authorizer operations

type RevokeTokenInput struct {
	RefreshToken string `json:"refresh_token"`
}

RevokeTokenInput defines attributes for /oauth/revoke request

type SessionQueryInput = SessionQueryRequest

SessionQueryInput is deprecated: Use SessionQueryRequest instead

type SessionQueryRequest struct {
	Roles []*string `json:"roles"`
	Scope []*string `json:"scope,omitempty"`
}

SessionQueryRequest defines attributes for session query request

type SignUpInput = SignUpRequest

SignUpInput is deprecated: Use SignUpRequest instead

type SignUpRequest struct {
	Email                    *string                `json:"email,omitempty"`
	Password                 string                 `json:"password"`
	ConfirmPassword          string                 `json:"confirm_password"`
	GivenName                *string                `json:"given_name,omitempty"`
	FamilyName               *string                `json:"family_name,omitempty"`
	MiddleName               *string                `json:"middle_name,omitempty"`
	NickName                 *string                `json:"nick_name,omitempty"`
	Picture                  *string                `json:"picture,omitempty"`
	Gender                   *string                `json:"gender,omitempty"`
	BirthDate                *string                `json:"birthdate,omitempty"`
	PhoneNumber              *string                `json:"phone_number,omitempty"`
	Roles                    []*string              `json:"roles,omitempty"`
	Scope                    []*string              `json:"scope,omitempty"`
	RedirectURI              *string                `json:"redirect_uri,omitempty"`
	IsMultiFactorAuthEnabled *bool                  `json:"is_multi_factor_auth_enabled,omitempty"`
	AppData                  map[string]interface{} `json:"app_data,omitempty"`
	State                    *string                `json:"state,omitempty"`
}

SignUpRequest defines attributes for signup request

type TokenQueryInput = GetTokenRequest

TokenQueryInput is deprecated: Use GetTokenRequest instead

type TokenResponse struct {
	AccessToken  string  `json:"access_token"`
	ExpiresIn    int64   `json:"expires_in"`
	IdToken      string  `json:"id_token"`
	RefreshToken *string `json:"refresh_token"`
}

TokenResponse defines attributes for token request

const (
	
	TokenTypeAccessToken TokenType = "access_token"
	
	TokenTypeIDToken TokenType = "id_token"
	
	TokenTypeRefreshToken TokenType = "refresh_token"
)
type UpdateProfileInput = UpdateProfileRequest

UpdateProfileInput is deprecated: Use UpdateProfileRequest instead

type UpdateProfileRequest struct {
	Email                    *string                `json:"email,omitempty"`
	NewPassword              *string                `json:"new_password,omitempty"`
	ConfirmNewPassword       *string                `json:"confirm_new_password,omitempty"`
	OldPassword              *string                `json:"old_password,omitempty"`
	GivenName                *string                `json:"given_name,omitempty"`
	FamilyName               *string                `json:"family_name,omitempty"`
	MiddleName               *string                `json:"middle_name,omitempty"`
	NickName                 *string                `json:"nick_name,omitempty"`
	Picture                  *string                `json:"picture,omitempty"`
	Gender                   *string                `json:"gender,omitempty"`
	BirthDate                *string                `json:"birthdate,omitempty"`
	PhoneNumber              *string                `json:"phone_number,omitempty"`
	Roles                    []*string              `json:"roles,omitempty"`
	Scope                    []*string              `json:"scope,omitempty"`
	RedirectURI              *string                `json:"redirect_uri,omitempty"`
	IsMultiFactorAuthEnabled *bool                  `json:"is_multi_factor_auth_enabled,omitempty"`
	AppData                  map[string]interface{} `json:"app_data,omitempty"`
}

UpdateProfileRequest defines attributes for update_profile request

type User struct {
	ID                       string                 `json:"id"`
	Email                    string                 `json:"email"`
	PreferredUsername        string                 `json:"preferred_username"`
	EmailVerified            bool                   `json:"email_verified"`
	SignupMethods            string                 `json:"signup_methods"`
	GivenName                *string                `json:"given_name"`
	FamilyName               *string                `json:"family_name"`
	MiddleName               *string                `json:"middle_name"`
	Nickname                 *string                `json:"nickname"`
	Picture                  *string                `json:"picture"`
	Gender                   *string                `json:"gender"`
	Birthdate                *string                `json:"birthdate"`
	PhoneNumber              *string                `json:"phone_number"`
	PhoneNumberVerified      *bool                  `json:"phone_number_verified"`
	Roles                    []*string              `json:"roles"`
	CreatedAt                int64                  `json:"created_at"`
	UpdatedAt                int64                  `json:"updated_at"`
	IsMultiFactorAuthEnabled *bool                  `json:"is_multi_factor_auth_enabled"`
	AppData                  map[string]interface{} `json:"app_data,omitempty"`
	RevokedTimestamp         *int64                 `json:"revoked_timestamp"`
}

User defines attributes for user instance

type ValidateJWTTokenInput = ValidateJWTTokenRequest

ValidateJWTTokenInput is deprecated: Use ValidateJWTTokenRequest instead

type ValidateJWTTokenRequest struct {
	TokenType TokenType `json:"token_type"`
	Token     string    `json:"token"`
	Roles     []*string `json:"roles,omitempty"`
}

ValidateJWTTokenRequest defines attributes for validate_jwt_token request

type ValidateJWTTokenResponse struct {
	IsValid bool                   `json:"is_valid"`
	Claims  map[string]interface{} `json:"claims"`
}

ValidateJWTTokenResponse defines attributes for validate_jwt_token response

type ValidateSessionInput = ValidateSessionRequest

ValidateSessionInput is deprecated: Use ValidateSessionRequest instead

type ValidateSessionRequest struct {
	Cookie string    `json:"cookie,omitempty"`
	Roles  []*string `json:"roles,omitempty"`
}

ValidateSessionRequest defines attributes for validate_session request

type ValidateSessionResponse struct {
	IsValid bool  `json:"is_valid"`
	User    *User `json:"user,omitempty"`
}

ValidateSessionResponse defines attributes for validate_session response

type VerifyEmailInput = VerifyEmailRequest

VerifyEmailInput is deprecated: Use VerifyEmailRequest instead

type VerifyEmailRequest struct {
	Token string  `json:"token"`
	State *string `json:"state,omitempty"`
}

VerifyEmailRequest defines attributes for verify_email request

type VerifyOTPInput = VerifyOTPRequest

VerifyOTPInput is deprecated: Use VerifyOTPRequest instead

type VerifyOTPRequest struct {
	Email       *string `json:"email"`
	OTP         string  `json:"otp"`
	PhoneNumber *string `json:"phone_number"`
	IsTotp      *bool   `json:"is_totp,omitempty"`
	State       *string `json:"state,omitempty"`
}

VerifyOTPRequest defines attributes for verify_otp request