How would one integrate Ory into a native Android app?

180 Views Asked by At

How can one integrate Ory into a native Android app? Is there any Android SDK available that I missed or does one really have to implement this from scratch with all the PKCE stuff etc?

1

There are 1 best solutions below

1
On BEST ANSWER

First, I shearch the last version on https://mvnrepository.com/search?q=ory

Then, I used the gradle version from https://mvnrepository.com/artifact/sh.ory/ory-client/1.1.31

implementation group: 'sh.ory', name: 'ory-client', version: '1.1.31'

And then, I used this sample

 public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://playground.projects.oryapis.com");

// Configure HTTP bearer authorization: oryAccessToken
HttpBearerAuth oryAccessToken = (HttpBearerAuth) defaultClient.getAuthentication("oryAccessToken");
oryAccessToken.setBearerToken("BEARER TOKEN");

CourierApi apiInstance = new CourierApi(defaultClient);
String id = "id_example"; // String | MessageID is the ID of the message.
try {
  Message result = apiInstance.getCourierMessage(id);
  System.out.println(result);
} catch (ApiException e) {
  System.err.println("Exception when calling CourierApi#getCourierMessage");
  System.err.println("Status code: " + e.getCode());
  System.err.println("Reason: " + e.getResponseBody());
  System.err.println("Response headers: " + e.getResponseHeaders());
  e.printStackTrace();
}
}

from https://github.com/ory/sdk/blob/master/clients/client/java/README.md#installation and it worked

Note: There is also a link where you can find all the Ory SDKs https://www.ory.sh/docs/sdk

Hope I helped with your problem :)