New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use username and password in REST API? #3560
Comments
If I set cookies |
Setting auth header doesn't work either. |
Doc says
I found it could be done like this. import requests
import json
data = {
"jsonrpc": "2.0",
"method":"force",
"id":843,
"params":{
"p1":1,
}
}
url = '127.0.0.1:8010'
s = requests.session()
s.head('http://{}/auth/login'.format(url), auth=('qsmobile', 'qsmobile'), proxies={'http':None})
r = s.post('http://{}/api/v2/forceschedulers/ForceBuild_Scheduler'.format(url), headers={'Content-Type':'application/json'}, data=json.dumps(data), proxies={'http':None}) |
Could you please add your scheduler and auth-roles from master.cfg? @seankelly please, add |
@Frodox c['www'] = dict(port=8010,
plugins=dict(
waterfall_view=True,
console_view=True),
allowed_origins=["*"]
)
c['www']['authz'] = util.Authz(
allowRules = [
util.AnyControlEndpointMatcher(role="admins")
],
roleMatchers = [
util.RolesFromUsername(roles=['admins'], usernames=['qsmobile', 'qsmobile'])
]
)
c['www']['auth'] = util.UserPasswordAuth([('qsmobile','qsmobile')]) scheduler: ForceBuild_Scheduler = ForceScheduler(
name="ForceBuild_Scheduler",
label=u"force",
builderNames=["BuildEntry_Builder"],
username=util.UserNameParameter(hide=True),
reason=util.StringParameter(name="reason", default="force build", hide=True),
codebases=[util.CodebaseParameter(codebase='', hide=True)],
properties=[util.IntParameter(name="param1",
label=u"param1",
default=1)]) |
I faced this as well while trying to figure out how to Authenticate the REST API. Current documentation doesn't explain that well. It would be nice to have the documentation updated. |
I want to use GET request to http://username:password@127.0.0.1:8010/api/v2/forceschedulers/{schedulername} to get information of the specified scheduler. Is there any reference?
At this time, I got a error message like this:
The text was updated successfully, but these errors were encountered: