serverlessworkflow / sdk-java

Java SDK for Serverless Workflow
http://serverlessworkflow.io
Apache License 2.0
76 stars 46 forks source link

Error parsing Oauth properties in cncf spec using java sdk #357

Closed ricardozanini closed 3 months ago

ricardozanini commented 3 months ago

Discussed in https://github.com/serverlessworkflow/specification/discussions/857

Originally posted by **mahith2108** May 23, 2024 Hi, we are using **Java sdk version **"4.0.5.Final"** and spec version: 0.8** as suggested (https://github.com/serverlessworkflow/sdk-java) I am trying to define Oauth properties using "auth" field in my spec as follows based on https://github.com/serverlessworkflow/specification/discussions/675 ```json "auth":[ { "name" : "serviceCloud", "scheme": "oauth2", "properties":{ "scopes": ["$$$$XXXMMMMM"], "audiences":["%%%XXXXXXX"] } }] ``` while parsing the spec using `Workflow.fromSource("")` I am getting following error. ```log Could not convert markup to Workflow: Unrecognized field "scopes" (class io.serverlessworkflow.api.auth.BasicAuthDefinition), not marked as ignorable (3 known properties: "password", "username", "metadata"]) at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: io.serverlessworkflow.api.Workflow["auth"]->io.serverlessworkflow.api.auth.BasicAuthDefinition["scopes"]) ``` we have tried following spec as well but the authDefinition.getOauth() is coming as null. ```json "auth":[ { "name" : "serviceCloud", "scheme": "oauth2", "oauth":{ "scopes": ["%%%%%X"], "audiences":["%%%XXXXXX"] } }] ``` ```java @JsonPropertyOrder({"name", "scheme", "basicauth", "bearerauth", "oauth"}) public class AuthDefinition implements Serializable { ```
ricardozanini commented 3 months ago

@mahith2108, FYI grantType and clientId are required for OAuth: https://github.com/serverlessworkflow/specification/blob/0.8.x/schema/auth.json#L191

I'll fix this validation and make sure the object conforms with the spec, thou.

mahith2108 commented 3 months ago

thanks