Oauth2 authorisation

Hello, please tell me how can I configure authorisation in the created application via Oauth2. WebView does not allow interaction with the authorisation page being opened, while the block for executing an API request does not allow authorisation. How can I solve this problem?

Do you want to use an API or pass an authorization header directly to a webview?
Webview should be able to store any auth cookie created during the browsing in that webview. For API you will need to create a new API Request.

There is an intra.42.fr service. It has an API server, api.intra.42.fr. When generating a URL for authorisation, the service sends it to the authorisation page, after which it is redirected and issued a token via a GET request. This token is then exchanged for an identifier via a POST request. Through this identifier, you can get information about the user through the API. When I paste the full authorisation link into the WebView, the application opens the authorisation page, but it does not come out to click on the authorisation button.

Here is the link for authorisation, which I need to open and enter the login details, get a token.

If I understand correct you need to split the auth in 2 steps.

  1. Take the token
  2. Exchange token with identifier

For the first step you will need to use the webview as you are doing already, but need to use the WebView Delegate (can be found in Protocol) to monitor for redirections and from the new url you will take the token.
For the second step, you need to add an API Request and the use the token from the first step.
You will need to use Code Blocks for these.

Thank you very much for your answer. With the second step, I more or less understand what to do. But can I ask for more detailed instructions for the first step? There are no descriptions for blocks and actions in the application, and I have not yet fully figured out the functions and capabilities.

Yeah of course.
So after you add the webview you need to go to Code Screen and then
Select protocols (1), then select WebviewDeletegate(2) and then add the function that it is called every time something loads in webview. There you will find the url in function arguments. You can use this parameter in an API call like in the screenshot. Don’t hesitate to ask for more if you need to.

Thank you very much. Right now I cannot try and check, but as soon as I get some result, I will definitely write. Thanks again.

Hello again. I can’t understand, where I make a mistake.

For redirection I need to push “Authorize” button, but WebView ignore any taps on buttons.

Have you setup the redirection url in the service that you are trying to auth? Does it redirect if you use Chrome or Safari(out of Kodika)?

Yes, the same url works perfect in chrome and safari. After tap on button, page redirect me to my test site where script make POST request to intra.42 and takes id-token.

Our latest version (2.5) should be able to solve this issue using a WebView Delegate