web services – Handling third-party OAuth2 tokens

After extensive research, I still don't know how to properly implement the following case. I think this question answers something similar, but I am not 100% sure (Should the client have access to the third-party API access token?).

Let's say I have my resource server (my-api.com), my identity provider and authorization server (my-idp.com) and I have a client application (native or browser) (com.my-app).

The standard use case is implemented with the authorization grant flow.

Now I have a new use case, where I need to request data from a third-party resource server (other-api.com). The third party also has an identity provider and offers OAuth 2.0 authorization and OpenID authentication flows. Third-party resource owners must consent to my request so that I can request their data and use it in my application.

This are my questions:

Is the flow in name what I need? It seems to be for two APIs that I control, not for third-party APIs.

How do I handle the third-party access, update and identification token to make requests on behalf of the resource owner?

  1. Could I store third-party tokens on my-api.com and add them to every request I make to request data for my user?
  2. Could I store third-party tokens on my-idp.com with my user information?
  3. You could send third-party tokens to com.my-app, which would result in two tokens for each part. This seems to be awkward.

I would go for option 2 and expand the functionality of my-idp.com. Is this a valid approach? My my-api.com API would then look for third-party tokens before making requests on behalf of my user.

Thank you.

error handling: Does Asp.Net Core expose too much information for the required enumerations that were not provided?

I have a simple code for an input model:

public class MyClass
    public MyEnum? Type { get; set; }

Now, if I don't send Type as part of json to the request, I receive this error from Web.Api:

"JSON value could not be converted to
System.Nullable`1 [MyNamespace.MyClass]. Path:
$ .type | Line number: 2 | BytePositionInLine: 16. "

This really looks like an exhibition of information to me, although I can't see any real danger in exactly this information, but still, more than anything.

Is it of any real concern or is it okay?

exceptions: handling errors in the Nest service layer

I would like to create a REST API with NestJs. But I want to add GraphQL as another higher level layer later. So, for starters, I have the basic layer controller, the service and the TypeORM repository. Suppose you want to update a user's username by id. The controller path could be

PATCH /users/:id/username

Two problems may arise in the service or repository layer:

  • User ID may not exist
  • Username already exist

The basic flow of this operation would be

  • Get the user by id
  • Handle error if the user does not exist
  • Check if the username already exists
  • Handle error if username already exists
  • Update the user's username

I'm thinking about how I should handle those mistakes. I could throw exceptions immediately based on this concept


NestJs provides some ready-to-use exceptions that I can use


The problem is that I don't think I should throw HTTP exceptions in my service layer. They must be thrown into the logic of my controller. So what is a common approach to those mistakes?

  • I must return? undefined instead of an updated user? The controller would not know which part failed.
  • Should I create my own exceptions by extending Error and throw them away?
  • Due to the fact that exceptions come with poor performance if the return type of the function is something like ?

magento2: Does Magento 2 offer .tar.gz file handling?

Magento 2 offers MagentoFrameworkArchiveTar to handle TAR files and MagentoFrameworkArchiveGz to handle Gz files.

Does Magento 2 offer a solution to directly decompress the .tar.gz files or do I have to do it myself by unpacking the .gz first and then the .tar?

polynomials – Zero handling with high precision

I am using Mathica to treat rational functions, $ p (x) / q (x) $, where the polynomials, $ p, q $ have a high degree and coefficients with a high order of precision, for example:

Out: {350,350,350,...}

The problem is that I need to use values ​​that change from x, and the rational function then seems

rational = p(x+7)/q(x+3)
Out:  (a(1) x+ a(2)x^2+...)/(0.*10^-280+b(1)x+...)

where a(n),b(n) they are real numbers When changing from x, of course, I lose some precision, so I'm fine (I also wouldn't mind being able to get more accuracy).

When i use rational as a rational function everything works fine, but sometimes I need to evaluate it in x=0. If I do it using rational/.x->0, I got the following error:

"Infinite expression 1/0.*10^-280 encountered"

while the correct answer should be a(1)/b(1). I managed to fix this error using


which gives me the correct answer However, I have many different polynomials and the loss of precision changes depends on their grade, coefficients, etc.

the rational function is an approximation of a function, which I to know It is not unique at the point evaluated, so I know that this zero precision is spurious. However, the coefficients are generated by another program over which I have no control, only high precision. Of course, that doesn't help here because by demanding more precision, it just pushed the problem forward.

Is there a way of best practices to deal with that kind of problem?

Medium format – Slight leaks in the handling of the RB67 film?

Recently I used a rental RB67 and when looking at the 120 negatives, I noticed a pattern of two types of possible light leaks throughout the film I filmed (but fortunately only in some images on each roll). As it was a rental, I don't have that camera anymore, so the problem can't be solved, so I'm just looking for a probable cause.

In the first case, there is a dark band that covers the numbers at the bottom of the negatives. This only seems to occur in the last 3 images or so on the roll, and interestingly this also seems to occur on one edge of the film. I suspect that when I removed the film from the camera, I did not keep the airtight envelope. Is my guess correct?

enter the description of the image here

The second problem I noticed is a probable leak of light in a corner of some paintings. There does not appear to be any pattern in which the frames have this leak. The only explanation I can think of is that I was changing the lenses and that the mirror was not sealing the film perfectly (and I was not using the dark slide when changing the lenses, is it a bad thing?) But when I look at the images on each side of the affected, all were taken with the same lens. This can be explained by changing the lens to test the field of vision and then returning to what it originally had. So, any ideas about this leak?

enter the description of the image here

error handling – How do I solve the portability of WP_Error?

I wrote a lot of code with the intention that it can be used not only in the WordPress space, but everywhere and, therefore, I have been very, very much against coming back WP_Errors and we resort to just returning bool When something went wrong Naturally, that is not enough because a Boolean gives you no context about what went wrong.

Is there a library / way to close the gap between WP_Errors and something that the entire PHP ecosystem understands? That is, if I take my code written primarily for WordPress and connect it to a non-WP environment, is there anything that guarantees that it will work when I return a Error?

error handling – What is Scala's best approach to translate from Try to Either?

I want to analyze a string class on a case by case basis. The valid format is {int}_{int}

I don't like to use Try as the return type for a function. Why?

  1. The main reason for this is that I try to avoid using native Java
    classes and especially Throwable.
  2. Exceptions are for exceptional
    cases. 🙂

I usually use Either with the description of the error or a case class with context information in the Left. As an example, using String in the Left.

So this is the question:

  1. What implementation do you prefer and why?
  2. Any other alternative implementation?
import org.scalatest.{Matchers, WordSpecLike}

import scala.util.{Failure, Success, Try}

object ExceptionHandlingExamples {

  case class CaseClass(a: Int, b: Int)

  def parseUsingMatchOnTry(str: String): Either(String, CaseClass) =
    str.split("_") match {
      case Array(a, b) =>
        Try(CaseClass(a.toInt, b.toInt)) match {
          case Success(c) => Right(c)
          case Failure(e) => Left(s"Error parsing ${str} => ${e.getMessage}")
      case _ => Left(s"(${str}) is not a valid format for a CaseClass")

  def parseUsingEitherIsomorphism(str: String): Either(String, CaseClass) =
    str.split("_") match {
      case Array(a, b) =>
        Try(CaseClass(a.toInt, b.toInt)).toEither.left
          .map(e => s"Error parsing ${str} => ${e.getMessage}")
      case _ => Left(s"(${str}) is not a valid format for a CaseClass")

  def parseUsingFold(str: String): Either(String, CaseClass) =
    str.split("_") match {
      case Array(a, b) =>
        Try(CaseClass(a.toInt, b.toInt))
            e => Left(s"Error parsing ${str} => ${e.getMessage}"),
            tileIdx => Right(tileIdx)
      case _ => Left(s"(${str}) is not a valid format for a CaseClass")


class ExceptionHandlingExamplesTest extends WordSpecLike with Matchers {

  import ExceptionHandlingExamples._

  "ExceptionHandlingExamples" when {

    "uses match on Try" in {
      parseUsingMatchOnTry("1_2") shouldBe Right(CaseClass(1, 2))
      parseUsingMatchOnTry("X_Y") shouldBe Left(
        "Error parsing X_Y => For input string: "X""

    "uses either isomorphism" in {
      parseUsingEitherIsomorphism("1_2") shouldBe Right(CaseClass(1, 2))
      parseUsingEitherIsomorphism("X_Y") shouldBe Left(
        "Error parsing X_Y => For input string: "X""

    "uses fold" in {
      parseUsingFold("1_2") shouldBe Right(CaseClass(1, 2))
      parseUsingFold("X_Y") shouldBe Left(
        "Error parsing X_Y => For input string: "X""


In addition to an essence: https://gist.github.com/angelcervera/e792cbcbb89f21b1cd6e7216e310106d

mobile: long text handling in designs with width restrictions

I am working on an application where occasionally there are single-word strings that must be represented in a box that is not wide enough to contain the intact word:

enter the description of the image here

The previous example is in German, but this also happens with rare words in English.

Does anyone have advice on how to deal with these types of texts? I could reduce the source or try to spread the word, but none of those approaches is bulletproof. We try to move the small icon in the lower left corner, but it looks horrible anywhere other than the lower left corner (for contextual reasons).

Any advice or thoughts others may offer would be greatly appreciated!