<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2" -->

---
title: Secure your CLI applications with OAuth (and Spring...
description: A walkthrough of securing a CLI application using OAuth 2.0 Device Code flow with Spring Security. The tutorial covers setting up a Spring Authorization...
canonical: https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Secure your CLI applications with OAuth (and Spring Security) | daily.dev
og:description: A walkthrough of securing a CLI application using OAuth 2.0 Device Code flow with Spring Security. The tutorial covers setting up a Spring Authorization...
og:url: https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2
og:image: https://api.daily.dev/og/posts/EsFTcL0y2.png
og:image:alt: Secure your CLI applications with OAuth (and Spring Security)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Secure your CLI applications with OAuth (and Spring Security)

**[Coffee \+ Software](https://daily.dev/sources/coffee-software)** · 13 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of securing a CLI application using OAuth 2.0 Device Code flow with Spring Security. The tutorial covers setting up a Spring Authorization Server, creating a protected REST endpoint as an OAuth resource server, and building a Spring Shell CLI client that authenticates users via the device code grant type. The CLI prompts users to visit a verification URL, polls for the access token, then uses it to call the secured backend API. The result can be compiled into a GraalVM native image for distribution.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=rLIQTY9Gg04>

## Similar posts on daily.dev

- [CLI Authentication, the Right Way](https://daily.dev/posts/cli-authentication-the-right-way-ybniyqoml) · Lobsters · 1 upvotes · 0 comments
- [Secure Your APIs: OAuth2 and JWT for Beginners](https://daily.dev/posts/secure-your-apis-oauth2-and-jwt-for-beginners-hh8guukwi) · JetBrains · 5 upvotes · 0 comments
- [OAuth 2.0 – Device flow explained for Engineers, especially for Backend Engineers](https://daily.dev/posts/oauth-2-0-device-flow-explained-for-engineers-especially-for-backend-engineers-dzube1gf7) · Stack Overflow Blog · 5 upvotes · 0 comments

---

Tags: [#spring-security](https://daily.dev/tags/spring-security)

[View this post on daily.dev](https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Secure your CLI applications with OAuth (and Spring Security)","url":"https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2"},"datePublished":"2026-03-16T08:14:04.570Z","dateModified":"2026-03-16T08:22:42.912Z","description":"A walkthrough of securing a CLI application using OAuth 2.0 Device Code flow with Spring Security. The tutorial covers setting up a Spring Authorization...","image":"https://i.ytimg.com/vi/rLIQTY9Gg04/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/rLIQTY9Gg04/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Coffee + Software","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Coffee + Software","logo":"https://media.daily.dev/image/upload/s--nAGLloYn--/f_auto,q_auto/v1773648811/logos/coffee-software?_a=BAMAMiiu0","url":"https://daily.dev/sources/coffee-software"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/secure-your-cli-applications-with-oauth-and-spring-security--esftcl0y2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"spring-security","timeRequired":"PT13M","video":{"@type":"VideoObject","name":"Secure your CLI applications with OAuth (and Spring Security)","description":"A walkthrough of securing a CLI application using OAuth 2.0 Device Code flow with Spring Security. The tutorial covers setting up a Spring Authorization...","thumbnailUrl":"https://i.ytimg.com/vi/rLIQTY9Gg04/sddefault.jpg","uploadDate":"2026-03-16T08:14:04.570Z","duration":"PT13M","url":"https://api.daily.dev/r/EsFTcL0y2","embedUrl":"https://www.youtube.com/embed/rLIQTY9Gg04"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Coffee + Software","item":"https://daily.dev/sources/coffee-software"},{"@type":"ListItem","position":3,"name":"Secure your CLI applications with OAuth (and Spring Security)"}]}
```

