OAuth - Value cannot be null or empty. Parameter name: code

Dear Markus/Experts,

I am trying to test OneIM API via Postman and over the postman while trying to use the OAuth Module as per documentation and passing the OAuth string with required values in the body of my API Call, getting the below error as shown below.

Can someone please advise if I am doing anything wrong

 [
{
"id": "OAuth",
"caption": "OAuth 2.0 / OpenID Connect",
"authTemplate": "Module=OAuth;(OAuth2Code)Code;(Hidden)AppUrl;(Hidden)ClientId;(Hidden)Nonce;(Hidden)RedirectUri",
"passwordBased": false,
"isDefault": false
}
]

2023-05-02 11:07:54.0524 ERROR (ObjectLog Global) : [810284] Failed to authenticate user.
[System.ArgumentException] Value cannot be null or empty.
Parameter name: code
System.AggregateException: One or more errors occurred. ---> VI.Base.ViException: Failed to authenticate user. ---> System.ArgumentException: Value cannot be null or empty.
Parameter name: code
at QER.OAuthAuthentifier.OAuth.<_GetTokenAsync>d__30.MoveNext()

Kindly assist.

Regards,

Debasis

Parents Reply
  • When I tried passing the bearer token header I am still getting 

    2023-05-11 13:24:08.9765 DEBUG (AppServer v2wZ9SO7H5ye8ThinEsg) : Executing request: /auth/apphost
    2023-05-11 13:24:08.9765 ERROR (ObjectLog Global) : [ServiceStack.HttpError] Invalid authentication data.
    ServiceStack.HttpError: Invalid authentication data.

    Also as you mention with token based auth, we don't need to call auth/apphost URL. so without calling auth/apphost URL, how will we authenticate ? What I understood from the documentation that in order to use RestAPI, we have to first  authenticate against the application server by calling auth/apphost with required module.

    For instance, when I used the dialoguser based auth module, I can successfully connect validate and make API calls via PostMan.

Children
  • If you configure the AppServer to use the token-based authentication, you do not need to call the auth/apphost URL. You instead provide the access token as a bearer token in the header of your call. This is meant for machine-to-machine usage.

    You have to keep in mind, that in this case OneIM converts the access token to an authenticated identity by taking a claim from the access token and using that to lookup a Person object as described in the authentication documentation for the OAuth authentication modules.

    If you use the other OAuth authentication modules, you need to call the auth/apphost URL as you did with the Dialoguser authentication module.