cwdrama Posted November 11, 2024 Posted November 11, 2024 Hello i want to deploye a app to use oauth2. Can anyone help me with an example code I made the request to a specific url.Input the credentials but after that i dont now how to get the code to use for taking the token Many thanks
Sherzod Posted November 11, 2024 Posted November 11, 2024 Hello, Are you using your own OAuth2 server or a third-party service (like Google, Facebook, etc.)? Could you provide a bit more detail on which service you're working with?
cwdrama Posted November 11, 2024 Author Posted November 11, 2024 we want to connect to a govermental oauth2 server. We made our request to them to enable the oauth2 authentication set the redirect url we want an the client id and secret and they enabled us to use them and now we want to deploy the code In the dsektop vcl app we have made it and works ok but cant deploy it with unigui thank you for your response
Sherzod Posted November 11, 2024 Posted November 11, 2024 Have you tried searching the forum? There are examples available on the forum, such as using Google services.
cwdrama Posted November 11, 2024 Author Posted November 11, 2024 i have searched many days find many examples and tested. I have a button that opens the website authorization url and i put there the credentials and after i hit the login button i dont now how to take the response to use the code value from there so i can use it to call then url to optain then token
cwdrama Posted November 11, 2024 Author Posted November 11, 2024 procedure TMainForm.UniButton1Click(Sender: TObject); var AuthURL: string; begin // The URL to initiate the OAuth flow (replace CLIENT_ID and REDIRECT_URI) AuthURL := 'https://xxxx/auth/authorize' + '?response_type=code' + '&client_id=xxxx' + '&redirect_uri=https://xxxx/callback' + '&scope=read' + '&state=cq123'; UniSession.UrlRedirect(AuthURL); end; With the above code the url is showing and i put the credentials.how can i then handle the response (After the user press the login button to validate his credentials. and get the code from the url it returns This is my proplem
Fred Montier Posted June 8 Posted June 8 In REDIRECT_URI make a endpoint in the same project and get the data they are sending back. You won't handle nothing redirect by uniSession. Is just sending a request without any endpoint to a server. See what is response, in most cases, a json and data in ARequestInfo you can open in servermodule command event. You should also make a code to relay the response to you session, or make a pure rest server. If it return a json to your request, for sure they provide some JS code for that. In this case, you can handling in the same form session in uniGUI. Like Paypal does. With just the in formation you provide, impossible to relay an true answer. Ask chatgpt for a solution in uniGUI and give the same name of the service. For sure its available in somewhere.
Recommended Posts