I would say that if you are not careful, the second option may be less RESTful than the first. REST is less about demutation and more about managing and focusing communication between the client and server.
In a calm system, you know that the connection between the client and the server lies in the definitions of the type of medium and the definitions of link relationships.
In both cases, you efficiently use types between client and server. In the first embodiment, this sharing is explicitly through a specific implementation that can be managed as a nuget package and versioned independently of the client and server.
In the second option, you have two implementations of common types. However, I assume that you are not planning to define a media type that explicitly defines the properties of these types. Therefore, you do not have a single source of truth, you have nothing to determine what data is concluded between the client and the server. How do you know when you’re about to make changes that break the client? At least with a shared library, you can know that the server now uses version 1.4.7 of the common types, and the client uses 1.3.9. You can use semantic versioning in a shared type library to know when you are committing a violation that will cause the client to update.
In the second option, you have a client and a secret that will be independently versioned, and it will be much harder to keep track of whether there are changes between the two versions.
Explanation Media types are always the best way to capture contracts and execute contracts between HTTP clients and servers. However, if you do not want to go there, then the nuget shared library is the best next step, because you isolate the part of the system that is used in conjunction with the client and server implementation. This is one of the key goals of REST. The fact that you are actually using the library for implementing this joint contract only affects users who live on other platforms that cannot use this library.
I coined the term Web Pack few years ago to describe this idea of ​​using the generic nuget package to store shared communications. I have written several articles here and here on this subject.
source share