// Convert_oauth_OAuthAuthorizeToken_To_v1_OAuthAuthorizeToken is an autogenerated conversion function.
190372
func Convert_oauth_OAuthAuthorizeToken_To_v1_OAuthAuthorizeToken(in *oauth.OAuthAuthorizeToken, out *v1.OAuthAuthorizeToken, s conversion.Scope) error {
	return autoConvert_oauth_OAuthAuthorizeToken_To_v1_OAuthAuthorizeToken(in, out, s)
}
1099715
func (m *tokenManager) ConvertToken(oauthToken oauth2.Token) (*TokenSet, error) {

	tokenSet := &TokenSet{
		AccessToken:  &oauthToken.AccessToken,
		RefreshToken: &oauthToken.RefreshToken,
		TokenType:    &oauthToken.TokenType,
	}

	var err error
	tokenSet.ExpiresIn, err = m.extraInt(oauthToken, "expires_in")
	if err != nil {
		return nil, err
	}
	tokenSet.RefreshExpiresIn, err = m.extraInt(oauthToken, "refresh_expires_in")
	if err != nil {
		return nil, err
	}
	tokenSet.NotBeforePolicy, err = m.extraInt(oauthToken, "not_before_policy")
	if err != nil {
		return nil, err
	}

	return tokenSet, nil
}
1127892
func Convert_oauth_OAuthRedirectReference_To_v1_OAuthRedirectReference(in *oauth.OAuthRedirectReference, out *v1.OAuthRedirectReference, s conversion.Scope) error {
	return autoConvert_oauth_OAuthRedirectReference_To_v1_OAuthRedirectReference(in, out, s)
}
436521
func Convert_authentication_TokenReviewStatus_To_v1beta1_TokenReviewStatus(in *authentication.TokenReviewStatus, out *v1beta1.TokenReviewStatus, s conversion.Scope) error {
	return autoConvert_authentication_TokenReviewStatus_To_v1beta1_TokenReviewStatus(in, out, s)
}
326888
func (s *Service) OAuthAuthorizationRegenerate(ctx context.Context, oauthAuthorizationIdentity string) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, s.Post(ctx, &oauthAuthorization, fmt.Sprintf("/oauth/authorizations/%v/actions/regenerate-tokens", oauthAuthorizationIdentity), nil)
}
416530
func Convert_authorization_LocalSubjectAccessReview_To_v1_LocalSubjectAccessReview(in *authorization.LocalSubjectAccessReview, out *v1.LocalSubjectAccessReview, s conversion.Scope) error {
	return autoConvert_authorization_LocalSubjectAccessReview_To_v1_LocalSubjectAccessReview(in, out, s)
}
1009479
func Convert_v1_TokenReviewStatus_To_authentication_TokenReviewStatus(in *v1.TokenReviewStatus, out *authentication.TokenReviewStatus, s conversion.Scope) error {
	return autoConvert_v1_TokenReviewStatus_To_authentication_TokenReviewStatus(in, out, s)
}
1232492
func Convert_v1_OAuthAccessToken_To_oauth_OAuthAccessToken(in *v1.OAuthAccessToken, out *oauth.OAuthAccessToken, s conversion.Scope) error {
	return autoConvert_v1_OAuthAccessToken_To_oauth_OAuthAccessToken(in, out, s)
}
1255020
func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error) {
	request.ParseForm()
	urlParts := request.URL.Query()
	token := urlParts.Get("oauth_token")
	verifier := urlParts.Get("oauth_verifier")
	if token == "" {
		token = request.Form.Get("oauth_token")
	}
	if verifier == "" {
		verifier = request.Form.Get("oauth_verifier")
	}
	if token == "" || verifier == "" {
		return "", "", fmt.Errorf("Token or verifier were missing from response")
	}
	return token, verifier, nil
}
476807
func Convert_v1_Action_To_authorization_Action(in *v1.Action, out *authorization.Action, s conversion.Scope) error {
	return autoConvert_v1_Action_To_authorization_Action(in, out, s)
}
791718
func Convert_image_SignatureSubject_To_v1_SignatureSubject(in *image.SignatureSubject, out *v1.SignatureSubject, s conversion.Scope) error {
	return autoConvert_image_SignatureSubject_To_v1_SignatureSubject(in, out, s)
}
1052157
func Convert_config_MasterAuthConfig_To_v1_MasterAuthConfig(in *config.MasterAuthConfig, out *v1.MasterAuthConfig, s conversion.Scope) error {
	return autoConvert_config_MasterAuthConfig_To_v1_MasterAuthConfig(in, out, s)
}
1363462
func Convert_v1_OAuthClientAuthorization_To_oauth_OAuthClientAuthorization(in *v1.OAuthClientAuthorization, out *oauth.OAuthClientAuthorization, s conversion.Scope) error {
	return autoConvert_v1_OAuthClientAuthorization_To_oauth_OAuthClientAuthorization(in, out, s)
}
258269
func Convert_oauth_OAuthClient_To_v1_OAuthClient(in *oauth.OAuthClient, out *v1.OAuthClient, s conversion.Scope) error {
	return autoConvert_oauth_OAuthClient_To_v1_OAuthClient(in, out, s)
}
696117
func Convert_oauth_OAuthClientAuthorization_To_v1_OAuthClientAuthorization(in *oauth.OAuthClientAuthorization, out *v1.OAuthClientAuthorization, s conversion.Scope) error {
	return autoConvert_oauth_OAuthClientAuthorization_To_v1_OAuthClientAuthorization(in, out, s)
}
321335
func Convert_config_BasicAuthPasswordIdentityProvider_To_v1_BasicAuthPasswordIdentityProvider(in *config.BasicAuthPasswordIdentityProvider, out *v1.BasicAuthPasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_config_BasicAuthPasswordIdentityProvider_To_v1_BasicAuthPasswordIdentityProvider(in, out, s)
}
1057465
func NewServicePrincipalTokenFromAuthorizationCode(oauthConfig OAuthConfig, clientID string, clientSecret string, authorizationCode string, redirectURI string, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) {

	if err := validateOAuthConfig(oauthConfig); err != nil {
		return nil, err
	}
	if err := validateStringParam(clientID, "clientID"); err != nil {
		return nil, err
	}
	if err := validateStringParam(clientSecret, "clientSecret"); err != nil {
		return nil, err
	}
	if err := validateStringParam(authorizationCode, "authorizationCode"); err != nil {
		return nil, err
	}
	if err := validateStringParam(redirectURI, "redirectURI"); err != nil {
		return nil, err
	}
	if err := validateStringParam(resource, "resource"); err != nil {
		return nil, err
	}

	return NewServicePrincipalTokenWithSecret(
		oauthConfig,
		clientID,
		resource,
		&ServicePrincipalAuthorizationCodeSecret{
			ClientSecret:      clientSecret,
			AuthorizationCode: authorizationCode,
			RedirectURI:       redirectURI,
		},
		callbacks...,
	)
}