# Java Vyou server sdk
This SDK is suitable to make server to server calls from client's backend to Vyou backend.
Here is an example:
fun getCustomer() {
val clientId = "eworitum2345ufw34589vwune4to8iwuertviwehrt"
val clientSecret = "dsfuafj9evt9w34j5vq0439vj5qoeiruveonitvuqwnoiuvq34095vuq34095v8"
val backendUrl = "https://vyou.vyou-dev.com:6120"
Sdk.init(clientId, clientSecret, backendUrl)
val accessToken = "eysoifqmwoeirumqw4095vq8340v598mq34059w59tomirtwiertu(...)"
val result = CustomerService.get(accessToken)
}
# Getting started
- Add
implementation("com.vyou:server-java:0.0.16")
in build.gradle.ks file - Initialize
Sdk
withSdk.init
method, providingclientId
,clientSecret
andbackendUrl
(this is the Vyou backend url).
# Customer
Customer.get(accessToken)
: retrieve customer information associated toaccessToken
Customer.create(newCustomer)
: creates a new customer.newCustomer
is of typeNewCustomer
whose properties are:
data class NewCustomer( val email: String, val privacyAccepted: Boolean, val termsAndConditionsAccepted: Boolean, val infoAccepted: Boolean )
Customer.update(accessToken, fieldsToUpdate)
: update a customer.fieldsToUpdate
is of typeFields
. Here is an example of how to build this structure:
Fields.Builder.put("name", "Juan").put("age", 33).build()
# Token Verifiers
These verifiers can check if vyou
accessToken
oridToken
are valid.IdTokenVerifier.verify(idToken)
: id token verification method.- If
idToken
is ok, it returnsIdTokenData
:
data class IdTokenData( val userId: String, val email: String )
- If
GatewayIdTokenVerifier.verify(idToken)
: X-Vyou-Token verification method.- If
X-Vyou-Token
is ok, it returnsGatewayIdTokenData
:
data class GatewayIdTokenData( val userId: String, val email: String, val accessToken: String )
- For more information about gateway, see Api gateway
- If
AccessTokenVerifier.verify(accessToken)
: access token verification method.- If
accessToken
is ok, it returnsAccessTokenData
:
data class AccessTokenData( val userId: String, val email: String, val roles: List<String> )
- If
# Payments
PaymentService.requestStripePayment(amount, metaData, accessToken)
: creates a payment intent, it returnsStripePaymentSecret
:data class StripePaymentSecret(val secret: String)
← iOS SDK Api gateway →