External Portal Authentication

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

External Portal Authentication

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
External Portal Authentication
External Portal Authentication
2023-01-19 19:14:29 - last edited 2023-01-19 19:42:31
Tags: #API #Authentication

Good afternoon
I'm trying to do an external portal authentication on an Omada Controller version 5.3.1.
I made an API in NET Core and based it on this documentation:
https://www.tp-link.com/br/support/faq/3231/

 

It worked until steps 10 and 11. I manage to generate the token.
According to the documentation, in steps 12 and 13 I make a request: POST api/v2/hotspot/extPortal/auth, passing the token in the header.

 

The strange thing is that in the example PHP code, there is another URL:
// API Call
curl_setopt($ch, CURLOPT_URL, "https://" . CONTROLLER . ":" . PORT . "/" . CONTROLLER_ID . "/api/v2/hotspot/login");

 

Using the first URL (steps 12 and 13), I have an error HTML to return. Trying the second URL (PHP code), authentication is performed again and a new token is generated.

 

Checking the documentation, it talks about saving cookie on controller request. Is this mandatory?

 

I don't know if I'm doing something wrong or need some Omada configuration.

  0      
  0      
#1
Options
2 Reply
Re:External Portal Authentication
2023-02-25 12:56:59

  @CliDigital 

 

Obviously, there is an error in the documentation provided near the public static function authorize($clientMac, $apMac, $ssidName, $radioId, $milliseconds)

 

if you scroll back at the documentation where Steps 12 and 13 begin, you will see the API end point:

https://CONTROLLER:PORT/CONTROLLER_ID/api/v2/hotspot/extPortal/auth

 

For the public static function authorize( ) to work, you will have to replace:
curl_setopt($ch, CURLOPT_URL, "https://" . CONTROLLER . ":" . PORT . "/" . CONTROLLER_ID . "/api/v2/hotspot/login");

 

with:
curl_setopt($ch, CURLOPT_URL, "https://" . CONTROLLER . ":" . PORT . "/" . CONTROLLER_ID . "/api/v2/hotspot/extPortal/auth");

 

Now you need to set the COOKIE_FILE_PATH constant to point to a file such as "./assets/cookie/jar.txt" and make sure the file is editable (in my case I did a "chmod -R 777 assets" because I am running my external portal server in Ubuntu). You asked if it is mandatory, YES you need to define cookie in the curl_setopt.

 

two requirements

 

 

 

 

 

One more thing, if you have no problem with getting the JSON response from "/api/v2/hotspot/login", then you must be able to get the JSON response from "api/v2/hotspot/extPortal/auth".

 

 

{

    "errorCode": 0

}

 

In my case, I have my Login/Authentication html page running in the same gateway where my Omada Controller is. My Omada Controller has an IP address 192.168.254.108 while my localhost server hosting the Login/Authentication html page has an IP address 192.168.254.109

I hope this gives a glimmer of clarity.

  3  
  3  
#2
Options
Re:External Portal Authentication
2023-02-27 17:19:35

  @Yuno23 

 

Thanks for your response.
As I mentioned, I'm adapting the documentation that uses a PHP project as an example for a C# project with .NET Core.

 

The documentation part is definitely a mistake.
Can you tell me how to adapt COOKIE_FILE_PATH to a request in C#?

 

In my case the controller and HTML file are on the same server.

  0  
  0  
#3
Options

Information

Helpful: 0

Views: 998

Replies: 2

Tags

API
Authentication
Related Articles