[p4python] Authentication problems

Daryl Spitzer daryl.spitzer at gmail.com
Fri Jul 25 14:39:16 PDT 2008


I'll answer my own question...

Replacing the p4.run_login() call with:

os.popen('echo %s | p4 -p %s -u %s login -a'
           % (P4PASSWD, P4PORT, P4USER))

...does the trick.  (And I removed the p4.password assignment.)

--
Daryl


On Tue, Jul 22, 2008 at 1:48 PM, Daryl Spitzer <daryl.spitzer at gmail.com> wrote:
> I'm trying to get some scripts that use P4Python working with a new
> Perforce server that uses ticket-based authentication.
>
> I looked at the example on page 71 of the "Perforce 2007.3 APIs for
> Scripting" document and tried running the following:
>
> from p4 import P4, P4Error
> P4PORT = '[REDACTED]:1666'
> P4USER = '[REDACTED]'
> P4PASSWD = '[REDACTED]'
> P4CLIENT = '[REDACTED]'
> p4 = P4()
> p4.port = P4PORT
> p4.user = P4USER
> p4.password = P4PASSWD
> p4.client = P4CLIENT
> p4.connect()
> p4.run_login(P4PASSWD)
> print p4.run_opened()
>
> ...and get:
>
> Traceback (most recent call last):
>  File "p4python_www_test.py", line 14, in <module>
>    p4.run_login(P4PASSWD)
>  File "/tools/python/2.5.1/linux64/lib/python2.5/site-packages/p4.py",
> line 190, in run
>    raise P4Error(string.join(self.errors, "\n"))
> p4.P4Error: Perforce password (P4PASSWD) invalid or unset.
>
> Then I saw the version on page 81, and tried not passing an argument
> to run_login(), and got:
>
> Traceback (most recent call last):
>  File "p4python_www_test.py", line 14, in <module>
>    p4.run_login()
>  File "/tools/python/2.5.1/linux64/lib/python2.5/site-packages/p4.py",
> line 190, in run
>    raise P4Error(string.join(self.errors, "\n"))
> p4.P4Error: No input provided and API wanted it
> Password invalid.
> 'p4auth' validation failed: p4auth.pl: Reading password for [REDACTED]
> from standard input
> p4auth.pl: Binding to LDAP server [REDACTED] as [REDACTED]
> p4auth.pl: Searching for [REDACTED]
> Authentication failed for [REDACTED]:
> The server requires the client which had attempted to bind anonymously or
> without supplying credentials to provide some form of credentials
>
> ----
>
> I want to make my script work independently of any environment variables.
>
> Neither variant of run_login() seems to work.  It may be telling that
> error from my second attempt says "Reading password...from standard
> input".
>
> Am I doing something wrong?  Or is this a mistake in the documentation?
>
> --
> Daryl Spitzer
>



More information about the p4python mailing list