Hi Team
I need some help in working with cookies. Flow is:
1. I will use the OAuth flow to get the access token(I'm getting it)
2. Use this token and hit our cookie url using the GET method(https://domain/CurrentAssessment/api/cookie)
I'm getting the access_token successfully but I'm not able to use it to send it to our cookie url. I've tried a lot of different ways and researched online but haven't had any success. Please note the token method below:
TokenMethod = (grantType, tokenField, code) =>
let
queryString = [
client_id=client_id,
scope= Json.Document(Extension.Contents("Source.json")) [source] [scope],
grant_type="password",
response_type="token",
username=username,
password=password
],
queryWithCode = Record.AddField(queryString, tokenField, code),
tokenResponse = Web.Contents(token_uri, [
Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),
Headers = [
#"Content-type" = "application/x-www-form-urlencoded",
#"Accept" = "application/json"
],
ManualStatusHandling = {400}
]),
body = Json.Document(tokenResponse),
result = if (Record.HasFields(body, {"error", "error_description"})) then
error Error.Record(body[error], body[error_description], body)
else
body
in
result;
I would appreciate any suggestions/help on this. Here is my powershell code which has the cookie method if it helps:
#Get the tenant cookie
$cookieResponse = Invoke-WebRequest -Method Get -Uri "https://$cloudUrl/CurrentAssessment/api/cookie" -Headers $requestHeaders -SessionVariable cookieSession -UseBasicParsing
$tenantCookie = $cookieSession.Cookies.GetCookies("https://$cloudUrl") | where Name -eq "CurrentAssessment"
User | Count |
---|---|
13 | |
3 | |
2 | |
2 | |
2 |