how do I clear interceptors? - interceptor

I have single okhttp3 client from DI.
the provided client has interceptors that I want to clear.
OkHttpClient.Builder newOkHttpClient = okHttpClient.newBuilder();
I am creating a new one using newBuilder but not sure I can clear interceptors.

Using newbuilder() does not clear the existing interceptors. You can customize a shared OkHttpClient instance with newBuilder(). This builds a client that shares the same connection pool, thread pools, and configuration. Use the builder methods to configure the derived client for a specific purpose.
This link should help you:-
https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html

Related

Can/Is the latest version of IdentityServer4 supports dynamic client add?

I assume I can build an additional API that registers users/apps/containers.
But is there a simpler way to accept multiple clients dynamically ?
That is for example, if my IDP is in the UK, and i would like to allow a predefined containers to "add themselves" to the client list of my IDP.
I achieved a simple "User -> Client -> IDP" authentication but would like to automate the process.
Thank you fellow coders.
In short, yes - but you'd have to create the mechanism to do so yourself.
If using a database to back your client storage (rather than using the default static/config file based in-memory store) then you're free to implement that any way you like.
In our solution we have an API that allows for this as well as a more limited self-serve UI capability.
There is an OpenID Connect spec for this that may provide some inspiration: https://openid.net/specs/openid-connect-registration-1_0.html
You can implement you own client store using IClientStore interface.
Something like
internal class MyCustomClientStore : IClientStore
{
public Task<Client> FindClientByIdAsync(string clientId)
{
throw new System.NotImplementedException();
}
}
You can store client data anywhere you want, interface is pretty simple.
This implementation can be registered using DI with
services
.AddIdentityServer()...
.AddClientStore<MyCustomClientStore>()

Not able to create events using Microsoft Graph SDK

I am trying to create an Event using Microsoft Graph SDK, as following the document #
https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-beta&tabs=csharp
1.Created "authProvider"
2.Created GraphClient with above AuthProvider
3.Creating Event using
The event is not creating also no exception/error is throwing, Could any one help me here?
This is happening because this call is being made with same transactionId frequently. It avoids unnecessary retries on the server.
It is an optional parameter , just comment out this property and try again. It should work.
Note : This identifier specified by a client app for the server , to avoid redundant POST operations in case of client retries to create the same event and also useful when low network connectivity causes the client to time out before receiving a response from the server for the client's prior create-event request.
More info is required here, as the reply from Allen Wu stated. without any details I would focus my efforts on the authprovider piece and azure app registration piece. as the rest of the example is just sending a post request to graph api.
but what is recommended really depends on what type of application you are trying to build. eg. is it a service daemon, a web app, mobile app, desktop app, single page app, etc.

Websocket with codename one

Will be be able to use the same websocket code for JS too? or is there any special code needed depending on platform?
Also will we be able to extend URLImage.createToStorage() method to load from our own websocket based backend rather than from URL? and will it be possible to make it work seamless in all devices?
It is possible to use websockets for the connection from a JavaScript build see this discussion. Notice that if you need to connect to a different server from the origin you will need to proxy your request to keep the same origin behavior.
You can't override the create methods of URLImage as they are all static. You can however download the files thru a websocket and open them using the EncodedImage.create method that accepts a byte array.

authentication/http headers support in forge.file trigger.io module?

in the official trigger.io docs there seems to be no provision for custom http headers when it comes to the forge.file module. I need this so I can download files behind an http authentication scheme. This seems like an easy thing to add, if support is not already there.
any workarounds? any chance of a quick fix in the next update? I know I could use forge.request instead, but I'd like to keep a local copy (saveURL).
thanks
Unfortunately the file module just uses simple "download url" methods rather than a full HTTP request library, which makes it a fairly big task to add support for custom headers.
I've added a task to our backlog for this, but I don't have a timeframe for it being added.
Currently on iOS you can do basic auth by using urls in the form http://user:password#url.com in case that helps.
Maybe to avoid this you can configure your server differently, or have a proxy server in front that allows you to pass authentication details as get parameters?

Can I implement callback from WCF based HTTP service to a gSOAP c/Linux client?

I have a Linux/c client app that connects to a WCF web service over HTTP/SOAP (BasicHTTPBinding). I am using gSOAP. Can I implement the calls to the web-service using callback? I want to get the data asynchronously as call back.
Update: I have updated the question title.
WCF does support Duplex services, or those that have the ability to call back to the requesting client. Duplex services can be very complicated, as they are not only stateful, but they impose an contract implementation requirement on their clients.
Duplex services require the use of the WSDuplexHttpBinding. You will need to make use of the OperationContext to get a reference to the callback channel. Your clients MUST implement the callback contract in some class, and provide an InstanceContext that contains an instance of the callback class to the client proxy. Communications in both directions must be supported, and if the client is behind its own firewall or across the internet, this can be a complicated matter to resolve. Take care when writing duplex services...they are often more trouble than they are worth...so make sure you really need it. ;-)
The following page might be helpful:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
The basicHttpBinding does not support callbacks. Another approach might be to have another method that the client can poll on for the response.
I am facing the same issue and the approach I am trying is to have a pair of gsoap servers/clients. Basically each process will listen on a port for soap calls and make its client calls to the other server. This way I avoid the polling or other complex approaches. The code has to be obviously thread safe for whatever business logic is implemented but the client/server combo pair is the simplest solution i have thought of so far.
Obviously one needs to be in control of both sides of the solutions the mentioned server and the mentioned client.

Resources