I am able to get on Docusign example page on my localhost:5000 fine but when I click on any of the 23 links it redirects me to localhost/ds/must_authenticate.
- I click on “authenticate with DocuSign” link and it takes me to account-d.docusign.com/#/password
-I enter my credentials and then it takes me appdemo.docusign.com/home
I am trying to do one of the many examples from the DocuSign GitHub repo on https://github.com/docusign/eg-03-python-auth-code-grant . The only thing I have changed is In the ds_config to add my client_id, client_secret, signer_email, signer_name, session_secret, and I had to add /oauth on line 14 in the ds_config. Changing it from authorization_server": "https://account-d.docusign.com to authorization_server": "https://account-d.docusign.com/oauth . The reason I added /oauth is because I get a client id error. The redirect URI I used in my integration key is http://localhost:5000/ds/callback. I guess I am having an issue with with the authorization_server. If I omit or keep brackets I get same results and can get past login. The url paths are : 127.0.0.1:5000 for homepage, then I click on any of the example links and get redirected to sign in page 127.0.0.1:5000/ds/must_authenticate, Then I click on the "authenticate with DocuSign" and get redirected to account.d.docusign.com/username#/password, then ""/password, then appdemo.docusign/authentication, then appdemo.docusign/redirect?to, then appdemo.docusign.com/home. I keep getting redirected to Docusign Homepage. If I take /oauth out of authorization server then I cant get past sign in page.
DocuSignIntegrationKeyandRedirectURI
OAuthSignInError DS_Config w/o brackets and w/o /oauth
DS_Config.py w/o brackets and w/o oauth
DS_CONFIG.PY
Thank you for submitting your question. On first glance, I see that your DS_Config.Py needs a couple of quick alterations. Can you try the following and let me know if you're still having issues with the OAuth flow?
1) Remove the { }'s from the config file. if you're listing your ds_client_id as {client_Id} it reads the {} as part of the ID, which will return an error indicating the key isn't properly registered with DocuSign. You'll want to remove the brackets from the first 5 variables in your config file.
2) Move the authorization_server back to the original URL (excluding '/oauth')
Let me know if that works for you, if you see another error on your side please reply with the exact error message with a screenshot if possible, then we can pick it up from there.
A current workaround I have found is editing the views.py ds_token_ok function. On line 177, the ok boolean variables are not returning true. Not sure if it is a session problem. I edited the return statement to return True instead of ok, this has let me open all the links in the python application and run all the examples.
def ds_token_ok(buffer_min=60):
# :param buffer_min: buffer time needed in minutes
#:return: true iff the user has an access token that will be good for #another buffer min
ok = "ds_access_token" in session and "ds_expiration" in session
ok = ok and (session["ds_expiration"] - timedelta(minutes=buffer_min)) > datetime.utcnow()
#comment: was return ok but I am not able to run program. Problem in line 177
return True
This is just a temporary solution to work in the sandbox.
Related
Getting the following error when trying to delete YouTube comments using Python. I can retrieve and set the moderation status of comments, but can't delete comments. Can't figure this out.
def deleteComments(service):
request = service.comments().delete(id="Ugzl8ec3rKxt6ClZlSR4AaABAg, 2CUswqQvx9q8MllybCuBF4AaABAg")
request.execute()
Error message:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/youtube/v3/comments?id=Ugzl8ec3rKxt6ClZlSR4AaABAg%2CUswqQvx9q8MllybCuBF4AaABAg returned "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid.">
Update:
The following code sample approved a comment, but generated an error message when trying to delete another comment. As suggested by #stvar, I added an exception to handle the error and retry the command after a brief delay to no avail. Not sure what else to do.
Code sample:
request = service.comments().setModerationStatus(
id="UgyVOfo6iFZPZ-lye9V4AaABAg",
moderationStatus=status
)
request.execute()
print("Approved comment "+"UgyVOfo6iFZPZ-lye9V4AaABAg")
i = 4
while True:
try:
request = service.comments().delete(
id="UgyVOfo6iFZPZ-lye9V4AaABAg"
)
request.execute()
print("Deleted comment "+"UgyVOfo6iFZPZ-lye9V4AaABAg")
break
except:
if (i>8):
break
time.sleep(i)
i=i+2
print("retry after 2 seconds")
Output:
Approved comment Ugys7LJAAAqXjruiM0h4AaABAg
retry after 2 seconds
retry after 2 seconds
retry after 2 seconds
I tried using curl, but was not successful because of issues getting an access token. I ended up just setting the moderation status of the comment to rejected. It's unfortunate that deleting comments using Python does not work for me. Maybe something is wrong on YouTube's end. Thank you.
Could it be that your comment ID
Ugzl8ec3rKxt6ClZlSR4AaABAg, 2CUswqQvx9q8MllybCuBF4AaABAg
is invalid for some reason? The IDs I recently saw were of the following format:
^U[a-zA-Z0-9_-]{25}(?:\.[a-zA-Z0-9_-]{22})?$
If you try to delete multiple comments in one shot, note that, according to the docs, the parameter id does not support a comma-separated list of IDs, as some other API endpoints do:
id (string)
The id parameter specifies the comment ID for the resource that is being deleted.
In such case, you'll have to issue separate calls to Comments.delete endpoint for each of your comments you need deleted.
Also note that the ID you pass to the API (the one I quoted above) is not the same as the one embedded within the error message you have shown:
Ugzl8ec3rKxt6ClZlSR4AaABAg,UswqQvx9q8MllybCuBF4AaABAg
This may indicate that the culprit for your error is not the API!
Note that you may remove only the comments that you've written yourself; that is that you cannot remove other people's comments.
Indeed this behavior of the API is not documented as such officially. But Google's staff mentioned that to be working as intended on Dec 6, 2016 00:24 UTC. A more recent mention is from Jun 15, 2019 22:33 UTC.
So, I am using API calls to get some json data, and I am using a for loop to execute the call using multiple ids which will return different data based on the user's id. So basically we need to update the permissions for some of our users so the json data looks somewhat like this for the users without permissions:
{"meta":{"httpStatus":"401 - Unauthorized","error":{"errorMessage":"Insufficient
permissions.","errorCode":"ARH_8.5"},"requestId":null}}
and this for users with the permissions:
{"result":{"elements":[{"id":"dslkjafsadl","name":"Test","ownerId"
:"sdfadfsfsda","lastModified":"2016","isActive":true},
{"id":"dsafsad","name":"Test","ownerId":"sdfasdfa","lastModified":"2016","isActive":true}],"nextPage":null},"meta":{"httpStatus":"200 - OK","requestId":"3242343"}}
so my question is if I have a big response with many results both with and without permissions how could I only pull the ids from the users with permissions, and exclude the ones without the permissions.
Say the response is stored in the variable "data" and the ids that I am looking for will be stored in "requestId" this is the code I tried:
requestId = request_id = [element['requestId'] for element in data['result']['elements']]
from this code I receive the a TypeError, and it doesn't recognize 'result' because the first response is a user without the correct permissions.
Best way is to check the http status code from the original request. Say you use the requests library to perform the GET to whatever resource, status_code of the requests object will contain 401 for permission denied.
Just relying on the code you already have, you can include a conditional statement as:
requestId = request_id = [element['requestId'] for element in data['result']['elements'] if element.get('meta').get('httpStatus') == '200 - OK']
which will basically only take elements where 'meta'.'httpStatus' is the desired one.
For the requests library, take a look here: http://docs.python-requests.org/
If you have control over your JSON:
One potential solution would be to consturct your json such that there's a parent node which describes the permissions of the returned result. For example:
{"permissions": false,
{"meta":{"httpStatus":"401 - Unauthorized","error":
{"errorMessage":"Insufficient permissions.","errorCode":"ARH_8.5"},
"requestId":null}
}
}
And
{"permissions": true,
{"result":{"elements":[{"id":"dslkjafsadl","name":"Test","ownerId"
:"sdfadfsfsda","lastModified":"2016","isActive":true},{"
id":"dsafsad","name":"Test","ownerId":"sdfasdfa","la
stModified":"2016","isActive":true}],"nextPage":null},"meta":{"h
ttpStatus":"200 - OK","requestId":"3242343"}}}
With this setup, just read the first value, and then structure your json-parsing code accordingly.
If your don't have control over the JSON:
In this case, you have to figure out which request you're receiving before you can really process it. One way to do this would be to read the names of the top keys.
In the case of the correct response, you could do something like this:
parsed_json = json.loads(json_string)
# The key "result" is only in the sucess response, not in the error response
if "result" in parsed_json:
# Success
else:
# Error
I'm using the djangoratings library found here and I have everything running and set up. In my views.py file I have a button which executes this line of code when pushed:
myinstance.rating.add(score=1, user=request.user, ip_address=request.META['REMOTE_ADDR'], request.COOKIES)
Everything works fine. The backend works, my columns are updated with the votes etc etc, but how can I access/call the IP and cookie fields and columns in djangoratings so that I can write a quick if condition that refuses to run the 'add' line if the cookies and IP have already voted?
Thanks in advance for any help. I've been really struggling with this a lot.
myinstance.rating contains method get_ratings() - which returns queryset to calculate all votes related to object. You can easily extend it for retrive necessary information. For example:
# it's lazy object
rating = myinstance.rating.get_ratings()
# do additional query for db
if not rating.filter(user=user, ip_address=request.META['REMOTE_ADDR']).exists():
...
How do I get the recent message corresponding to reviewer":{"name":"Klocwork Automation User"
INPUT:-
{"project":"platform/frameworks/opt/telephony","branch":"kitkat","id":"Idcf6faee0f6259704ea07b62ce713ebdd4c5da1b","number":"739919","subject":"Correct order of parameter in iccExchangeApdu()","owner":{"name":"Satish Kumar Singh","email":"c_ssing#qca.qualcomm.com","username":"c_ssing"},"url":"https://review-android.quicinc.com/739919","createdOn":1399412660,"lastUpdated":1399418924,"sortKey":"002ce960000b4a4f","open":true,"status":"NEW","comments":[{"timestamp":1399412661,"reviewer":{"name":"Gator Service Account","email":"gator#localhost","username":"gator"},"message":"Patch Set 1: Looks good to me, but someone else must approve\n\nThis patchset has been processed by the Gator."},{"timestamp":1399412704,"reviewer":{"name":"Checkpatch Service Account","email":"checkpatch#localhost","username":"checkpatch"},"message":"Patch Set 1: Looks good to me, but someone else must approve\n\nYour change has passed all of the checks enforced by the android patchchecker."},{"timestamp":1399413456,"reviewer":{"name":"Satish Kumar Singh","email":"c_ssing#qca.qualcomm.com","username":"c_ssing"},"message":"Patch Set 1: Developer Build and Test Successful\n\n"},{"timestamp":1399415354,"reviewer":{"name":"Gueyoung Lee","email":"gueyoung#qca.qualcomm.com","username":"gueyoung"},"message":"Patch Set 1: Looks good to me, but someone else must approve\n\n"},{"timestamp":1399417092,"reviewer":{"name":"Dhananjai Singh","email":"dhananja#qca.qualcomm.com","username":"dhananja"},"message":"Patch Set 1: Looks good to me, but someone else must approve\n\n"},{"timestamp":1399417366,"reviewer":{"name":"David Ng","email":"dng#quicinc.com","username":"dng"},"message":"Patch Set 1: Looks good to me, approved\n\nI remembered the previous change went in recently. How come this was not caught in the original testing as this would have failed right away?\n\nThanks!\nDavid"},{"timestamp":1399418880,"reviewer":{"name":"Klocwork Automation User","email":"kwuser#localhost","username":"kwuser"},"message":"Patch Set 1:\n\nThis change is being verified in klocwork for the following manifests along with other changes as detailed below:\n\n\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\ngit-android.quicinc.com/platform/manifest:kk:default.xml\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nhttps://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId\u003d3217513\n\n--------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n o https://review-android.quicinc.com/#change,\n\n\n\nPlease note that verification of all changes in this batch need to be successful before this change can be merged.\n\nPLEASE DO NOT UPLOAD A NEW PATCH SET, OR REMOVE APPROVALS UNTIL THE VERIFICATION IS COMPLETE.\n"},{"timestamp":1399418898,"reviewer":{"name":"Linux Build Service Account","email":"lnxbuild#localhost","username":"lnxbuild"},"message":"Patch Set 1:\n\nThis change is being verified in lookahead for the following manifests along with other changes as detailed below:\n\n\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\ngit-android.quicinc.com/platform/manifest:kk:default.xml\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nhttps://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId\u003d3217515\n\n--------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n o https://review-android.quicinc.com/#change,739919\n\n\n\nPlease note that verification of all changes in this batch need to be successful before this change can be merged.\n\nPLEASE DO NOT UPLOAD A NEW PATCH SET, OR REMOVE APPROVALS UNTIL THE VERIFICATION IS COMPLETE.\n"},{"timestamp":1399418924,"reviewer":{"name":"Linux Build Service Account","email":"lnxbuild#localhost","username":"lnxbuild"},"message":"Patch Set 1:\n\nThis change is being verified in lookahead for the following manifests along with other changes as detailed below:\n\n\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\ngit-android.quicinc.com/platform/manifest:kk:default.xml\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nhttps://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId\u003d3217517\n\n--------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n o https://review-android.quicinc.com/#change,739919\n\n\n\nPlease note that verification of all changes in this batch need to be successful before this change can be merged.\n\nPLEASE DO NOT UPLOAD A NEW PATCH SET, OR REMOVE APPROVALS UNTIL THE VERIFICATION IS COMPLETE.\n"}]}
{"type":"stats","rowCount":1,"runTimeMilliseconds":3}
I copied the first line of your input into stringdata = u'''...'''
Then load it into json
import json
dict_data =json.loads(stringdata.replace('\n','') )
You need to manually examine the data structure
for c in dict_data ['comments']:
if c['reviewer']['name'].startswith('Klocwork'): # you can use exact search
print c['message']
The output is:
Patch Set 1:This change is being verified in klocwork for the following manifests along with other changes as detailed below:=====================================================================================git-android.quicinc.com/platform/manifest:kk:default.xml=====================================================================================https://commander.qualcomm.com/commander/pages/SimplifiedJobView/LoadComponent_run?jobId=3217513-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- o https://review-android.quicinc.com/#change,Please note that verification of all changes in this batch need to be successful before this change can be merged.PLEASE DO NOT UPLOAD A NEW PATCH SET, OR REMOVE APPROVALS UNTIL THE VERIFICATION IS COMPLETE.
I'm working on Linkedin REST API. I cannot get postions' end-date.
connectionsdic = application.get_connections(selectors=['id',
'positions','specialties','first-name','last-name',
'headline','public-profile-url','site-standard-profile-request'],
params=`{'start':130, 'count':100})
I can get anything else.
Edit: I changed my code to be most straight, but still same result...
Try just specifying positions without the :['end-date'] part, in the same you specify educations.
Also note that end date will not be returned if the position is current.