Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added java support for auth-provider #336

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions packages/auth-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,23 @@ run inside [python virtual env](https://docs.python.org/3/library/venv.html)
pip install affinidi_tdk_auth_provider
```

## Java

## Usage
### Install Java package

update dependencies (for eg: v1.29.0)

```java
<dependency>
<groupId>com.affinidi.tdk</groupId>
<artifactId>auth-provider</artifactId>
<version>1.29.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/auth-provider/1.29.0/auth-provider-1.29.0.jar</systemPath>
</dependency>
```

## Usage

### Python package usage

Expand Down Expand Up @@ -62,7 +76,30 @@ const authProvider = new AuthProvider({
const projectScopedToken = await authProvider.fetchProjectScopedToken()
```

### Mnually Build JSII python package
### Java package usage

```java
import com.affinidi.tdk.authprovider.*;

private static AuthProvider getAuthProvider() {
Map<String, String> params = new HashMap<>();
params.put("projectId", dotenv.get("PROJECT_ID"));
params.put("tokenId", dotenv.get("TOKEN_ID"));
params.put("keyId", dotenv.get("KEY_ID"));
params.put("privateKey", dotenv.get("PRIVATE_KEY").replace("\\n", System.getProperty("line.separator")));
params.put("passphrase", dotenv.get("PASSPHRASE"));

// Create an instance of AuthProvider
AuthProvider authProvider = new AuthProvider(params);
return authProvider;
}

AuthProvider authProvider = getAuthProvider();

String projectScopedToken = authProvider.fetchProjectScopedToken();
```

### Manually Build JSII python package

This is step is required, as python package is not published to pypi.org yet

Expand All @@ -77,3 +114,27 @@ npm run package
```bash
pip install dist/python/affinidi_tdk_auth_provider-0.1.4-py3-none-any.whl
```

### Manually Build JSII java package

This is step is required, as python package is not published to pypi.org yet

```bash
git clone git@github.com:affinidi/affinidi-tdk.git
cd packages/auth-provider/
npm i --prefix .
npm run build
npm run package
```

update dependencies (for eg: v1.29.0)

```java
<dependency>
<groupId>com.affinidi.tdk</groupId>
<artifactId>auth-provider</artifactId>
<version>1.29.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/auth-provider/1.29.0/auth-provider-1.29.0.jar</systemPath>
</dependency>
```
Loading
Loading