
com.stytch.java.b2b.api.organizationsmembersoauthproviders.OrganizationsMembersOAuthProviders.kt Maven / Gradle / Ivy
package com.stytch.java.b2b.api.organizationsmembersoauthproviders
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.GithubResponse
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.GoogleResponse
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.HubspotResponse
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.MicrosoftResponse
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.ProviderInformationRequest
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.SlackRequest
import com.stytch.java.b2b.models.organizationsmembersoauthproviders.SlackResponse
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
import com.stytch.java.http.HttpClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture
public interface OAuthProviders {
/**
* Retrieve the saved Google access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*
* Google One Tap does not return access tokens. If the member has only authenticated through Google One Tap and not
* through a regular Google OAuth flow, this endpoint will not return any tokens.
*
* __Note:__ Google does not issue a refresh token on every login, and refresh tokens may expire if unused.
* To force a refresh token to be issued, pass the `?provider_prompt=consent` query param into the
* [Start Google OAuth flow](https://stytch.com/docs/b2b/api/oauth-google-start) endpoint.
*/
public suspend fun google(data: ProviderInformationRequest): StytchResult
/**
* Retrieve the saved Google access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*
* Google One Tap does not return access tokens. If the member has only authenticated through Google One Tap and not
* through a regular Google OAuth flow, this endpoint will not return any tokens.
*
* __Note:__ Google does not issue a refresh token on every login, and refresh tokens may expire if unused.
* To force a refresh token to be issued, pass the `?provider_prompt=consent` query param into the
* [Start Google OAuth flow](https://stytch.com/docs/b2b/api/oauth-google-start) endpoint.
*/
public fun google(
data: ProviderInformationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Retrieve the saved Google access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*
* Google One Tap does not return access tokens. If the member has only authenticated through Google One Tap and not
* through a regular Google OAuth flow, this endpoint will not return any tokens.
*
* __Note:__ Google does not issue a refresh token on every login, and refresh tokens may expire if unused.
* To force a refresh token to be issued, pass the `?provider_prompt=consent` query param into the
* [Start Google OAuth flow](https://stytch.com/docs/b2b/api/oauth-google-start) endpoint.
*/
public fun googleCompletable(data: ProviderInformationRequest): CompletableFuture>
/**
* Retrieve the saved Microsoft access token and ID token for a member. After a successful OAuth login, Stytch will save
* the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
* access token automatically.
*/
public suspend fun microsoft(data: ProviderInformationRequest): StytchResult
/**
* Retrieve the saved Microsoft access token and ID token for a member. After a successful OAuth login, Stytch will save
* the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
* access token automatically.
*/
public fun microsoft(
data: ProviderInformationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Retrieve the saved Microsoft access token and ID token for a member. After a successful OAuth login, Stytch will save
* the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
* access token automatically.
*/
public fun microsoftCompletable(data: ProviderInformationRequest): CompletableFuture>
/**
* Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider.
*/
public suspend fun slack(data: SlackRequest): StytchResult
/**
* Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider.
*/
public fun slack(
data: SlackRequest,
callback: (StytchResult) -> Unit,
)
/**
* Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider.
*/
public fun slackCompletable(data: SlackRequest): CompletableFuture>
/**
* Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*/
public suspend fun hubspot(data: ProviderInformationRequest): StytchResult
/**
* Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*/
public fun hubspot(
data: ProviderInformationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
* issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh
* the
* access token automatically.
*/
public fun hubspotCompletable(data: ProviderInformationRequest): CompletableFuture>
/**
* Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
* issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
* tokens after very long periods of inactivity.
*/
public suspend fun github(data: ProviderInformationRequest): StytchResult
/**
* Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
* issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
* tokens after very long periods of inactivity.
*/
public fun github(
data: ProviderInformationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
* issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
* tokens after very long periods of inactivity.
*/
public fun githubCompletable(data: ProviderInformationRequest): CompletableFuture>
}
internal class OAuthProvidersImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : OAuthProviders {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override suspend fun google(data: ProviderInformationRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(ProviderInformationRequest::class.java).toJson(data)
val type = Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)
val adapter: JsonAdapter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy