I'm trying to query api.whatever.com, but I also want to pass a USERNAME, such as in curl it would look like this:
https://USERNAME#api.whatever.com/
How do I write the client request in such a way that USERNAME gets sent properly to the API server.
You need to base64 encode the username.
url = "https://USERNAME#api.whatever.com/".replace("https://","").split("#");
// Buffer is global, no need for require.
url64 = "https://" + (new Buffer(url[0]).toString('base64')) + url[1];
http://en.wikipedia.org/wiki/Basic_access_authentication
There's an explaination of the format you have to use as well as an example.
Related
I want Bosun to make an API call to JIRA, which requires a basic authentication in a form of BASE64 encoded string username:password. What keyword I can use in the notification definition to pass the authentication token to JIRA? My basic notification looks like this:
notification jira_alert {
post = https://example.com:8081/rest/api/2/issue/createmeta
contentType = application/json
Reading the documentation on bosun.org I can't find any specific keyword I could use. Any hints?
Can you put put the key in URL or in JSON data?
For example:
notifaction chat {
next = email
timeout = 10m
post - http://chat.example.com/room/1?key=KEY&message=whatever
}
Can someone explain how do I compute a HMAC
===============
To verify that the request came from Shopify, compute the HMAC digest according to the following algorithm and compare it to the value in the X-Shopify-Hmac-SHA256 header. If they match, you can be sure that the Webhook was sent from Shopify and the data has not been compromised.
Each Webhook request includes a X-Shopify-Hmac-SHA256 header which is generated using the app's shared secret, along with the data sent in the request.
I have the secret key... how can I combine the secret key + the data in the request to generate a HMAC
The easiest way is to use the ShopifySharp Library. You can use the Nuget package and install it in your project.
This is an example taken from the ShopifySharp website for validating webhooks:
NameValueCollection requestHeaders = Request.Headers;
Stream inputStream = Request.InputStream;
if(AuthorizationService.IsAuthenticWebhook(requestHeaders, inputStream, shopifySecretKey))
{
//Webhook is authentic.
}
else
{
//Webhook is not authentic and should not be acted on.
}
If you don't want to use ShopifySharp, you can see how they implemented it in the source code.
I am developing a Command Line Tool in Swift 3, i have this code:
let url = "www.google.com"
var request = URLRequest(url:url)
request.httpMethod = "GET"
let task = session.dataTask(with: a){ (data,response,error) in
print("REACHED")
handler(response,data)
}
task.resume()
I cannot reach the task if i use "http://" or "https://" as prefix in any url, i am wondering if i need a App Transport Security plist, i already tried create a simple plist, anyone knows some if has a particularity for this problem?
When specifying a URL, you need the "scheme" (e.g. http:// or https://).
The url is a URL, not a String, so it should be:
let url = URL(string: "http://www.google.com")!
Yes, you need Info.plist entry if you want to use http://. E.g. https://stackoverflow.com/a/37552442/1271826 or Transport security has blocked a cleartext HTTP or just search stack overflow for "[ios] http info.plist" or with [osx].
Note, in Xcode 8.1, console apps don't necessarily have a Info.plist file, so if you don't have one, you may have to add one by pressing command+n:
update your target settings to specify the plist:
and then add the appropriate settings, e.g.:
I assume where you have URLRequest(with: a) you meant URLRequest(with: request).
You'll need something to keep the command app alive while you're performing the request (e.g. a semaphore or something like that).
I'm trying to send verification mail but it showing some error
my error is URI malformed
First,error screenshot
I added email package and at the server side i added something like
Accounts.config({
sendVerificationEmail:true
});
i set env_url like this
process.env.MAIL_URL = 'smtp://postmaster%sandbox.mailgun.password#smtp.mailgun.org:587';
URIs use percent encoding for reserved characters, and a % by itself is invalid. Also, there should be a : between the username and the password (see the docs). This should be the format you want:
'smtp://postmaster%40sandbox.mailgun:password#smtp.mailgun.org:587'
which decodes to:
'smtp://postmaster#sandbox.mailgun:password#smtp.mailgun.org:587'
I want to access html files which are protected by basic authentication.
I am trying to load this html page using htmlloader and sending the request by urlRequest.
I am using URLRequestDefaults class to set the credentials but when I see the request being send in the fiddler I don't see any authorization header being set by this.
Am I doing something wrong here. My code is below.
URLRequestDefaults.authenticate = false;
URLRequestDefaults.setLoginCredentialsForHost("www.xyz.com", "madhur", "sharma");
var req:URLRequest = new URLRequest("http://bazinga.xyz.com/MyHtml/index.html");
htmlControl.htmlLoader.load(urlRequest);
You should read the API more carefully:
Note that "example.com", "www.example.com", and "sales.example.com" are each considered unique hosts.
In this case, the domains don't match.