Skip to content

Commit 80fb3b3

Browse files
authored
[77019][77024] Hosted Authentication Imporovments (#39)
This PR provides two minor improvements to Hosted Authentication. 1. Added in the missing email authentication scope 2. Added support for force_password setting during hosted authentication
1 parent ffc8df7 commit 80fb3b3

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ This section contains changes that have been committed but not yet released.
66

77
### Added
88

9+
- Added support for the `forced_password` Hosted Auth setting
10+
911
### Changed
1012

13+
- Added missing `EMAIL` scope
14+
1115
### Deprecated
1216

1317
### Fixed

src/examples/java/com/nylas/examples/hostedAuth/HostedAuthUrlExample.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static void main(String[] args) throws Exception {
1919
.scopes(Scope.values())
2020
.loginHint(conf.get("hosted.login.hint"))
2121
.state("example_csrf_token")
22+
.forcePassword(true)
2223
.buildUrl();
2324

2425
System.out.println("Forward the user to this URL for hosted authentication:");

src/main/java/com/nylas/HostedAuthentication.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static class UrlBuilder {
6262
private String scopes = "";
6363
private String loginHint = "";
6464
private String state = "";
65+
private boolean forcePassword = false;
6566

6667
UrlBuilder(NylasApplication app) {
6768
this.app = app;
@@ -130,6 +131,15 @@ public UrlBuilder state(String state) {
130131
this.state = state;
131132
return this;
132133
}
134+
135+
/**
136+
* An optional setting for when using a password or wanting to choose a different
137+
* provider than auto selected
138+
*/
139+
public UrlBuilder forcePassword(boolean forcePassword) {
140+
this.forcePassword = forcePassword;
141+
return this;
142+
}
133143

134144
private void validate() {
135145
assertState(!nullOrEmpty(redirectUri), "Redirection URI is required");
@@ -157,6 +167,9 @@ public String buildUrl() {
157167
if (!nullOrEmpty(state)) {
158168
urlBuilder.addQueryParameter("state", state);
159169
}
170+
if (forcePassword) {
171+
urlBuilder.addQueryParameter("force_password", "true");
172+
}
160173

161174
return urlBuilder.build().toString();
162175
}

src/main/java/com/nylas/Scope.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
*/
88
public enum Scope {
99

10+
/**
11+
* Read, modify, and send all messages, threads, file attachments, and read email metadata like headers.
12+
*/
13+
EMAIL("email"),
14+
1015
/**
1116
* Read and modify all messages, threads, file attachments, and read email metadata like headers.
1217
* Does not include send.

0 commit comments

Comments
 (0)