[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] Authorization Token Request Assistance



Are you sure that shouldn't be a POST instead of a GET?

When I copy your URI to a browser I get:
AADSTS900561: The endpoint only accepts POST, OPTIONS requests. Received a GET request.

I've written front ends for MS Graph APIs (Office 365) before and normally these are POSTs...   

Also, I've never used an actual tenant, but "common" instead.

<vendor>See https://www.bvstools.com/g4ms.html (GreenTools for Microsoft Apps) for what may already be available for what you're doing if you're interested in possibly saving some time and headaches. </vendor>



On Mon, Mar 8, 2021 at 2:13 PM Weaver, Corby <corby.weaver@xxxxxxxxxxxxx> wrote:

I’ve modified my code as suggested. However, I’m still not getting the Authorization Token in return. I do have the debug log. Everything looks like it is connecting properly. It looks to me like the credentials aren’t being passed properly.

 

My code:

URL = "" href="https://login.microsoftonline.com/+" target="_blank">https://login.microsoftonline.com/+                                 

     535b2d87-664f-415a-b7fa-fd3f1086d450/oauth2/token'                    

     + '?grant_type=client_credentials'                                    

     + '&client_id="' + http_urlEncode(%TRIM(ClientID))                    

     + '"&client_secret="' + http_urlEncode(%Trim(ClientSecret) + '"');    

                                                                            

http_xproc( http_point_addl_header: %paddr(AddHeader));                    

response = http_string('GET':URL);                                         

 

Results in “response” and in the log:

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->                                              

<!DOCTYPE html>                                                                                                 

<html dir="ltr" class="" lang="en">                                                                              

<head>                                                                                                          

    <title>Sign in to your account</title>                                                                       

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">                                         

    <meta http-equiv="X-UA-Compatible" content="IE=edge">                                                       

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">

    <meta http-equiv="Pragma" content="no-cache">                                                               

    <meta http-equiv="Expires" content="-1">                                                                     

    <link rel="preconnect" href="" href="https://aadcdn.msauth.net" target="_blank">https://aadcdn.msauth.net" crossorigin>                                        

<meta http-equiv="x-dns-prefetch-control" content="on">                                                          

<link rel="dns-prefetch" href="" href="http://aadcdn.msauth.net" target="_blank">aadcdn.msauth.net">                                                            

<link rel="dns-prefetch" href="" href="http://aadcdn.msftauth.net" target="_blank">aadcdn.msftauth.net">                                                           

                                                                                                                 

    <meta name="PageID" content="ConvergedError" />                                                             

    <meta name="SiteID" content="" />                                                                           

    <meta name="ReqLC" content="1033" />                                                                        

    <meta name="LocLC" content="en-US" />                                                                        

 

Here are the results if I run this in Postman:

"token_type":"Bearer","expires_in":"3599","ext_expires_in":"3599","expires_on":"1615237458","not_before":"1615233558","resource":"00000002-0000-0000-c000-000000000000","access_token":

 

 

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Jose Fondeur
Sent: Wednesday, February 10, 2021 7:14 AM
To: FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Ftpapi] Authorization Token Request Assistance

 

 

  [CAUTION]  This email originated from outside Core-Mark. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 


Hi,

 

Just curious. Your request has "&client_Id:' instead of "&client_id=' as indicated by the vendor's documentation. Same with "&client_secret:". 

Request =                                                      

'HTTP/1.1 Host: login.microsoftonline.com +                    

    Content-Type: application/x-www-form-urlencoded +          

    Cache-Control: no-cache +                                  

    grant_type=client_credentials+                            

    &client_id:' + %TRIM(ClientID) +                          

    '&client_secret:' +                                        

    %Trim(ClientSecret);                                      

 

 


From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> on behalf of John Long <John.Long@xxxxxxxxxxxxxx>
Sent: Wednesday, February 10, 2021 2:32 AM
To: FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Ftpapi] Authorization Token Request Assistance

 

Hi,

 

In addition to Scots suggestion, can I also suggest you use http_debug

 

You can then see details details of what you are creating by looking in the IFS at the output. 

 

You can then compare this to the raw view in Postman, it becomes very obvious what you are doing wrong. 

Regards,

 

John

 

Development Manager



On 9 Feb 2021, at 23:13, Weaver, Corby <corby.weaver@xxxxxxxxxxxxx> wrote:



I have a process that needs to obtain an authorization token each time it is run. I've seen a few posts to this forum that are along the same line, but none seem to have a resolution. One says you do not need to do a GET, but only do a SETAUTH. Not seeing a whole lot with that. 

 

The documentation from the vendor has this example for the token request:

GET /535b2d87-664f-415a-b7fa-fd3f1086d450/oauth2/token HTTP/1.1 

Host: login.microsoftonline.com Content-Type: application/x-www-form-urlencoded 

Cache-Control: no-cache

 

grant_type=client_credentials&client_id=XXXXXXXXXX&client_secret=XXXXXXXXXXX

 

 

Here is my chunk of code...

 

URL = "" href="https://urldefense.com/v3/__https:/protect-eu.mimecast.com/s/o_KQCY7DVIZ7lZf0GCjh?domain=login.microsoftonline.com__;!!DjJsWdbdCQ!OQOQINKdU4cQ7guhx-A-nLoHQU6Nt-TWNrgN6i6g72gLIT00b__VoZCV6t0JULThJ8Ww7A$" target="_blank">https://login.microsoftonline.com/+                    

       535b2d87-664f-415a-b7fa-fd3f1086d450/oauth2/token';    

                                                               

Request =                                                      

'HTTP/1.1 Host: login.microsoftonline.com +                    

    Content-Type: application/x-www-form-urlencoded +          

    Cache-Control: no-cache +                                  

    grant_type=client_credentials+                            

    &client_id:' + %TRIM(ClientID) +                          

    '&client_secret:' +                                        

    %Trim(ClientSecret);                                      

                                                               

response = http_string( 'GET': URL: Request);                  

                                                               

In my httplog, I get an error that says the request body must contain "grant_type".

 

I'm able to successfully obtain my token using Postman. I'm guessing there's a syntax thing going on or I'm just missing something.

 

Any help would be appreciated

 

Corby Weaver

Core-Mark Midcontinent, Inc.  DBA Farner-Bocken Company

Email: corby.weaver@xxxxxxxxxxxxx

 

3D1E3150

 

--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
https://protect-eu.mimecast.com/s/a3puCZ8EZIR6gRujjwFr?domain=scottklement.com


 
The information contained in this communication from john.long@xxxxxxxxxxxxxx sent at 2021-02-10 07:32:49 is confidential and may be legally privileged or protected by other legal rules. This e-mail (and any attachments) is intended solely for use by ftpapi@xxxxxxxxxxxxxxxxxxxxxx and may contain personal views which are not the views of the TJ Morris Ltd unless specifically stated. If you are not ftpapi@xxxxxxxxxxxxxxxxxxxxxx, please contact the sender by reply e-mail and destroy all copies of the original message. You should not copy it or disclose its contents to any other person.

--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi