Earlier I had asked a question about how to raise a pull request from command line and with help I came up with this code to get it done:
curl -k -X POST -H "Content-Type: application/json" --user username:password -d '{"title":"test","description":"test","fromRef":{"id":"branchone","repository":{"slug":"TrialRepo","name":null,"project":{"key":"~SS48647"}}},"toRef":{"id":"master","repository":{"slug":"TrialRepo","name":null,"project":{"key":"~SS48647"}}}}' https://url/bitbucket/rest/api/1.0/projects/~SS48647/repos/trialrepo/pull-requests
The thing is this code will run in production environment and username and password can't be plain-texted.
I was thinking if it'd be possible to use SSH Keys for user-authentication. I will generate keys on a unix machine and I will add the public key to Bitbucket. Please add your views on how to get this done. Also, if there's a better way to avoid plain-texted user-authentication it'd be great. Thanks
I guess it is about a Bitbucket Server instance here, right?
According this documentation there is just Basic Authentication, OAuth or Session Authentication. https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication
One addition to Basic Authentication are the Personal Access Tokens, which can be generated per user and can be used as a password too: https://confluence.atlassian.com/bitbucketserver0516/personal-access-tokens-966061199.html#Personalaccesstokens-usingpersonalaccesstokens
But, I guess for you the most proper solution would be to create an Application Link and use OAuth.