Skip to content

Instantly share code, notes, and snippets.

View stefanozanella's full-sized avatar

Stefano Zanella stefanozanella

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stock purchase created</title>
</head>
<body>
<p>Stock purchase created.</p>
<p th:text="${stockPurchase.ticker}" />
<p th:text="${stockPurchase.purchaseDate}" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add stock purchase</title>
</head>
<body>
<h2>Add a stock purchase</h2>
<form method="post" th:action="@{/stock_purchase}" th:object="${stockPurchase}">
<p>
package me.stefanozanella.sampleapp
import com.sksamuel.avro4k.Avro
import org.apache.avro.generic.GenericRecord
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.kafka.core.KafkaTemplate
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
dependencies {
// ...
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
// ...
}
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.2"
id("io.spring.dependency-management") version "1.0.12.RELEASE"
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
}
group = "me.stefanozanella"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo App</title>
</head>
<body>
<a href="https://app-eu1.hubspot.com/oauth/authorize?client_id=<your client ID>&redirect_uri=https://yourlocal.app/oauth2/callback/hubspot&scope=crm.objects.leads.read%20settings.users.read">
Connect Hubspot
</a>
dependencies {
// ...
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
// ...
}
@Configuration
class WebSecurityConfig {
@Bean
fun oauth2Configuration(http: HttpSecurity): SecurityFilterChain =
http
.oauth2Client()
.and()
.oauth2Login()
.redirectionEndpoint()
.baseUri("/oauth2/callback/*")
@Controller
class HomeController {
@GetMapping("/")
fun home() = "home"
}
spring:
security:
oauth2:
client:
registration:
hubspot:
authorization-grant-type: authorization_code
client-id: your-client-id
client-secret: your-client-secret
redirect-uri: https://yourlocal.app/oauth2/callback/hubspot