[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Posting Requests To Microsoft Azure
It should be doable in RPG...
But I don't know that anyone on the list has done it.� What you want
to do is look around the web for code showing how to access�Azure
services from other languages...
Or even without using the library MS provides.
I found this:
[1]http://blog.davidebbo.com/2015/12/calling-arm-using-plain-rest.html
The sample code linked to in the
article,�[2]https://github.com/davidebbo/AzureWebsitesSamples/blob/mas
ter/HttpClientSample/AuthenticationHelpers.cs
Has the following:
� � � � const string ARMResource =
"[3]https://management.core.windows.net/";
� � � � const string TokenEndpoint =
"[4]https://login.windows.net/{0}/oauth2/token";
� � � � const string SPNPayload =
"resource={0}&client_id={1}&grant_type=client_credentials&client_secret
={2}";
� � � � public static async Task<string> AcquireTokenBySPN(string
tenantId, string clientId, string clientSecret)
� � � � {
� � � � � � var payload = String.Format(SPNPayload,
� � � � � � � � � � � � � � � � � � � � WebUtility.UrlEncode(ARMResource),
� � � � � � � � � � � � � � � � � � � � WebUtility.UrlEncode(clientId),
� � � � � � � � � � � � � � � � � � � � WebUtility.UrlEncode(clientSecret));
� � � � � � var body = await HttpPost(tenantId, payload);
� � � � � � return body.access_token;
� � � � }
So we know that getting a token just requires a properly formatted HTTP
POST.
Looks MS provides the source not only for the .NET ADAL library but for
other languages including Java and Node.js.
[5]https://azure.microsoft.com/en-us/documentation/articles/active-dire
ctory-authentication-libraries/
Digging into those should provide everything you need to figure out how
the POST need to be sent.
Though a quicker and easier solution would be to use Java or Node.js
from the i.
Let us know how it turns out.
Charles
On Thu, Mar 31, 2016 at 8:21 AM, Paul Park <[6]parkp@xxxxxxxxxx> wrote:
Hi
I have a new requirement to post requests to a REST web service
hosted on a Microsoft Azure platform.� I've had success in the past
using Scott's HTTPAPI service program to post XML requests to a SOAP
service, and I believe that posting to REST should be no problem
either.
I have two stumbling blocks that I know of, though, and they are
shown on a page that explains how to make requests to the new
service -
[7]https://msdn.microsoft.com/en-us/library/azure/mt428036.aspx.
I'll list them here:
1) "To make a data request to the Data Catalog REST service, you
need to supply an access token. In a .NET client app, you use the
Windows Azure Authentication Library (ADAL) to get an access token."
string authorityUri =
"[8]https://login.windows.net/common/oauth2/authorize";
� AuthenticationContext authContext = new
AuthenticationContext(authorityUri);
� AuthenticationResult token =
authContext.AcquireToken(resourceUri, clientId, new
Uri(redirectUri), PromptBehavior.RefreshSession);
2) "After you get an access token from Active Directory (AAD), you
use the token to make a web request to the Data Catalog REST API. To
create a Data Catalog REST web request, you add an access token to a
request header."
I have no idea how to tackle step 1 - get an access token. The
example is .NET, and I suspect I can't do this.
Step 2 - add the token to a request header might be possible, as
I've seen examples that use http_setauth to pass a user id and
password. Can I use http_setauth to send an access token?
I've already prepared my boss for disappointment on this, but I need
to know: is there a way to do step 1 in RPG?
Thanks for any input.
Paul
Enterprise Software Systems.
Company No 3374336. Registered in England,
Registered Office: Enterprise House, Pacific Road
Altrincham, Cheshire, WA14 5EN
The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
email
by anyone else is unauthorized. If you are not the intended
recipient, any
disclosure, copying, distribution or any action taken or omitted to
be
taken in reliance on it, is prohibited and may be unlawful. If you
are not
the intended addressee please contact the sender and dispose of this
e-mail.
--------------------------------------------------------------------
---
This is the FTPAPI mailing list.� To unsubscribe, please go to:
[9]http://www.scottklement.com/mailman/listinfo/ftpapi
--------------------------------------------------------------------
---
References
1. http://blog.davidebbo.com/2015/12/calling-arm-using-plain-rest.html
2. https://github.com/davidebbo/AzureWebsitesSamples/blob/master/HttpClientSample/AuthenticationHelpers.cs
3. https://management.core.windows.net/
4. https://login.windows.net/{0}/oauth2/token
5. https://azure.microsoft.com/en-us/documentation/articles/active-directory-authentication-libraries/
6. mailto:parkp@xxxxxxxxxx
7. https://msdn.microsoft.com/en-us/library/azure/mt428036.aspx
8. https://login.windows.net/common/oauth2/authorize
9. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------