cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1698
Views
0
Helpful
6
Replies

Logout in SDWAN API

Hi,

 

I've been using the SD-Wan API and it worked with no problems.

 

But, when I'm trying to do the logout I'm not able to get the code 302. I think it has to do with the random-number that appears in the code snippet.

 

anyone knows what am I suppose to insert in random-number field ?

 

 

image.png

 

 Thank you,

 

Gonçalo Freitas

 

 

6 Replies 6

@GoncaloFreitas61868 typically I sent a GET request 

 

https://{{vmanage}}:{{port}}/logout?nocache

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Hi ,
Thank you for your answer.

I know that I have to do a GET request , but as you can see in the code snippet is mentioned “random-number “ (after nocache) that is what I don’t know how to fill

Thank you ,
Best Regards,

Gonçalo Freitas

@GoncaloFreitas61868 the XSRF token should be in the http header.

 

 https://www.cisco.com/c/en/us/td/docs/routers/sdwan/configuration/sdwan-xe-gs-book/cisco-sd-wan-API-cross-site-request-forgery-prevention.html

 

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Thank you one more time for your answer.
I think I didn't express myself clearly.
I can to the login with credentials and then use the received token to do the following requests.
What I don't know is how I can obtain the code 302 by executing the code above since I'm using the session Id in the header and the correct URL.
That's why I think the problem come from the random number which I don't know what it is.
Do you know how to build it.
Best Regards,
Gonçalo Freitas

It will be google translation.

Please use the cookie used to acquire the token.
If there are no Session updates, you're probably fine.

It's a powershell sample, and I think it's hard to read.

$get_Cookie_params = @{
body = "j_username=admin&j_password=$password"
uri = "https://$vmanaggIpAddress/j_security_check"
headers = @{"Content-Type" = "application/x-www-form-urlencoded"}
method = "Post"
}
$get_Cookie_result = Invoke-WebRequest @get_Cookie_params -SessionVariable mySession


$get_token_params = @{
uri = "https://$vmanaggIpAddress/dataservice/client/token"
method = "Get"
}
$get_token_result = Invoke-WebRequest @get_token_params -WebSession $mySession

##Session storage for logout
$log_out_onlye_Session = $mySession


~Processing using token~


$delet_token_params = @{
uri = "https://$vmanaggIpAddress/logout?nocache"
method = "get"
headers = @{"Content-Type" = "application/x-www-form-urlencoded"; "X-XSRF-TOKEN" = $get_token_result.Content}
}
$out_put=Invoke-WebRequest @delet_token_params -WebSession $log_out_onlye_Session


##https://www.postman.com/ciscodevnet/workspace/cisco-devnet-s-public-workspace/request/3224967-d388ca2d-523e-49e1-b143-fcfad0b2cc2c
##Headers refer to the above.www.postman.com_ciscodevnet_workspace_cisco-devnet-s-public-workspace_request_3224967-d388ca2d-523e-49e1-b143-fcfad0b2cc2c.png

You have not correctly pushed the updated cookie to the service that issued the token. I think it's
To say the least.

200/OK came out.
Unfortunately, it is unclear if the token is actually returned, as it differs from the original document.

> $out_put


StatusCode : 200
StatusDescription : OK
Content : <html>
<head>
<meta charset="utf-8">
<title>Cisco SD-WAN</title>
<link rel="stylesheet" type="text/css" href="/styles/login.css">
<link rel="stylesheet" type="text/css" href="/fonts/fo...
RawContent : HTTP/1.1 200 OK
x-xss-protection: 1; mode=block
pragma: no-cache,no-cache
x-frame-options: DENY
content-security-policy: default-src 'self' *.walkme.com;script-src 'self' https://cdn.walkme.com ht...
Forms : {loginForm}
Headers : {[x-xss-protection, 1; mode=block], [pragma, no-cache,no-cache], [x-frame-options, DENY], [content-security-policy, default-src 'self' *.walkme.com;script-src 'self' https://cdn.walkme.com https://maps.googleapis.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src '
self' data: * ; font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com/ data:; form-action 'self' https://*.pingidentity.com https://*.pingone.com; frame-src 'self' https://cdn.walkme.com; connect-src 'self' https://*.walkme.com; object-src 'none']...}
Images : {@{innerHTML=; innerText=; outerHTML=<IMG class=center alt="Cisco SD-WAN" src="/images/sdwan_logo.svg">; outerText=; tagName=IMG; class=center; alt=Cisco SD-WAN; src=/images/sdwan_logo.svg}, @{innerHTML=; innerText=; outerHTML=<IMG alt="Login Error" src="/images/error.svg">; outerText=; tag
Name=IMG; alt=Login Error; src=/images/error.svg}, @{innerHTML=; innerText=; outerHTML=<IMG class=spinner alt=Loader src="/images/loader.png">; outerText=; tagName=IMG; class=spinner; alt=Loader; src=/images/loader.png}}
InputFields : {@{innerHTML=; innerText=; outerHTML=<INPUT id=j_username class=login-input-value maxLength=64 name=j_username autocomplete="off" autofocus oninput="setView('1')" placeholder="Username">; outerText=; tagName=INPUT; id=j_username; class=login-input-value; maxLength=64; name=j_username; autoc
omplete=off; autofocus=; oninput=setView('1'); placeholder=Username}, @{innerHTML=; innerText=; outerHTML=<INPUT onkeyup=validateTacForm() id=j_challenge class=login-input-value size=34 name=j_challenge autocomplete="off" placeholder="Challenge Key">; outerText=; tagName=INPUT; onkeyup=vali
dateTacForm(); id=j_challenge; class=login-input-value; size=34; name=j_challenge; autocomplete=off; placeholder=Challenge Key}, @{innerHTML=; innerText=; outerHTML=<INPUT onchange=copyToClipboard() id=copy_challenge type=checkbox value="">; outerText=; tagName=INPUT; onchange=copyToClipboa
rd(); id=copy_challenge; type=checkbox; value=}, @{innerHTML=; innerText=; outerHTML=<INPUT onchange="getChallenge('rekey')" id=refresh_challenge type=checkbox value="">; outerText=; tagName=INPUT; onchange=getChallenge('rekey'); id=refresh_challenge; type=checkbox; value=}...}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 7013

 

jibanezvela
Level 1
Level 1

Hi Gonzalo

Maybe too late, but here my test.

I used "null" or empty as random number, I'm not geting the 302 code, or I'm not able to see that, I see a 200 code status and the login page, I tested with firefox and python with "session" module from "request" library.

But I checked in the user_sessions web page: https://vmanage-1.sdwan.cisco.com/#/app/administration/manage_users/user_sessions  , and the session was released.

Regards,

JI

Review Cisco Networking for a $25 gift card