How to handle expired access token in asp.net core using refresh token with OpenId Connect

It seems there is no programming in the openidconnect authentication for asp.net core to manage the access_token on the server after received. I found that I can intercept the cookie validation event and check if the access token has expired. If so, make a manual HTTP call to the token endpoint with the grant_type=refresh_token. By … Read more

Yahoo Finance Historical data downloader url is not working

I recently wrote a simple python script to download the history of a single stock. Here an example how to invoke it: python get_quote_history.py –symbol=IBM –from=2017-01-01 –to=2017-05-25 -o IBM.csv This will download IBM historical prices from 2017-01-01 to 2017-05-25 and save them in IBM.csv file. import re import urllib2 import calendar import datetime import getopt … Read more

How to add a cookie to the cookiejar in python requests library

Quick Answer Option 1 import requests s = requests.session() s.cookies.set(“COOKIE_NAME”, “the cookie works”, domain=”example.com”) Option 2 import requests s = requests.session() # Note that domain keyword parameter is the only optional parameter here cookie_obj = requests.cookies.create_cookie(domain=”example.com”,name=”COOKIE_NAME”,value=”the cookie works”) s.cookies.set_cookie(cookie_obj) Detailed Answer I do not know if this technique was valid when the original question was … Read more

Sending cookies with postman

I used the postman chrome extension until it became deprecated. Chrome extension is also less usable and powerful than the native postman application. Hence it became very inconvenient to use the chrome extension. I have found another approach: copy any request in chrome/any other browser as a CURL request import to postman copied request save … Read more

How do I access HttpContext in Server-side Blazor?

Add the following to Blazor.Web.App.Startup.cs: services.AddHttpContextAccessor(); You also need this in <component-name>.cshtml @using Microsoft.AspNetCore.Http @inject IHttpContextAccessor httpContextAccessor Note: At the time when this answer was written, accessing the HttpContext was done as described above. Since then, Blazor has been under rapid development, and has fundamentally changed. It is definitely deprecated the usage described above, but … Read more

Same-Site flag for session cookie in Spring Security

New Tomcat version support SameSite cookies via TomcatContextCustomizer. So you should only customize tomcat CookieProcessor, e.g. for Spring Boot: @Configuration public class MvcConfiguration implements WebMvcConfigurer { @Bean public TomcatContextCustomizer sameSiteCookiesConfig() { return context -> { final Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor(); cookieProcessor.setSameSiteCookies(SameSiteCookies.NONE.getValue()); context.setCookieProcessor(cookieProcessor); }; } } For SameSiteCookies.NONE be aware, that cookies are also Secure … Read more

how to disable cookies using webdriver for Chrome and FireFox JAVA

I’ve just get solution for Firefox: FirefoxProfile profile = new ProfilesIni().getProfile(“default”); profile.setPreference(“network.cookie.cookieBehavior”, 2); driver = new FirefoxDriver(profile); for Chrome (block all cookies) ChromeOptions options = new ChromeOptions(); options.AddUserProfilePreference(“profile.default_content_setting_values.cookies”, 2); for Chrome (block only third party cookies) ChromeOptions options = new ChromeOptions(); options.AddUserProfilePreference(“profile.default_content_setting_values.cookies”, 1); options.AddUserProfilePreference(“profile.cookie_controls_mode”, 1);