@@ -522,13 +522,59 @@ type interactiveAuthOptions struct {
522522 claims , domainHint , loginHint , redirectURI , tenantID string
523523 openURL func (url string ) error
524524 authnScheme AuthenticationScheme
525+ successPage []byte
526+ errorPage []byte
525527}
526528
527529// AcquireInteractiveOption is implemented by options for AcquireTokenInteractive
528530type AcquireInteractiveOption interface {
529531 acquireInteractiveOption ()
530532}
531533
534+ func WithSuccessPage (successPage []byte ) interface {
535+ AcquireInteractiveOption
536+ options.CallOption
537+ } {
538+ return struct {
539+ AcquireInteractiveOption
540+ options.CallOption
541+ }{
542+ CallOption : options .NewCallOption (
543+ func (a any ) error {
544+ switch t := a .(type ) {
545+ case * interactiveAuthOptions :
546+ t .successPage = successPage
547+ default :
548+ return fmt .Errorf ("unexpected options type %T" , a )
549+ }
550+ return nil
551+ },
552+ ),
553+ }
554+ }
555+
556+ func WithErrorPage (errorPage []byte ) interface {
557+ AcquireInteractiveOption
558+ options.CallOption
559+ } {
560+ return struct {
561+ AcquireInteractiveOption
562+ options.CallOption
563+ }{
564+ CallOption : options .NewCallOption (
565+ func (a any ) error {
566+ switch t := a .(type ) {
567+ case * interactiveAuthOptions :
568+ t .errorPage = errorPage
569+ default :
570+ return fmt .Errorf ("unexpected options type %T" , a )
571+ }
572+ return nil
573+ },
574+ ),
575+ }
576+ }
577+
532578// WithLoginHint pre-populates the login prompt with a username.
533579func WithLoginHint (username string ) interface {
534580 AcquireInteractiveOption
@@ -671,7 +717,7 @@ func (pca Client) AcquireTokenInteractive(ctx context.Context, scopes []string,
671717 if o .authnScheme != nil {
672718 authParams .AuthnScheme = o .authnScheme
673719 }
674- res , err := pca .browserLogin (ctx , redirectURL , authParams , o .openURL )
720+ res , err := pca .browserLogin (ctx , redirectURL , authParams , o .openURL , o . successPage , o . successPage )
675721 if err != nil {
676722 return AuthResult {}, err
677723 }
@@ -709,13 +755,13 @@ func parsePort(u *url.URL) (int, error) {
709755}
710756
711757// browserLogin calls openURL and waits for a user to log in
712- func (pca Client ) browserLogin (ctx context.Context , redirectURI * url.URL , params authority.AuthParams , openURL func (string ) error ) (interactiveAuthResult , error ) {
758+ func (pca Client ) browserLogin (ctx context.Context , redirectURI * url.URL , params authority.AuthParams , openURL func (string ) error , successPage [] byte , errorPage [] byte ) (interactiveAuthResult , error ) {
713759 // start local redirect server so login can call us back
714760 port , err := parsePort (redirectURI )
715761 if err != nil {
716762 return interactiveAuthResult {}, err
717763 }
718- srv , err := local .New (params .State , port )
764+ srv , err := local .New (params .State , port , successPage , errorPage )
719765 if err != nil {
720766 return interactiveAuthResult {}, err
721767 }
0 commit comments