-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
104c2d9
commit 3812e3e
Showing
53 changed files
with
2,083 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/example/springOAuth/config/GoogleCredentialProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.example.springOAuth.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import lombok.Data; | ||
|
||
@ConfigurationProperties("google") | ||
@Configuration | ||
@Data | ||
public class GoogleCredentialProperties { | ||
|
||
private CredentialDetails credentials = new CredentialDetails(); | ||
|
||
@Data | ||
public static class CredentialDetails { | ||
|
||
private String client_id; | ||
private String client_secret; | ||
private String auth_uri; | ||
private String token_uri; | ||
private String auth_provider_x509_cert_url; | ||
private List<String> redirect_uris = new ArrayList<>(); | ||
|
||
private String redirectUrl; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/example/springOAuth/controller/InstalledAppsControlled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.example.springOAuth.controller; | ||
|
||
import java.io.IOException; | ||
import java.security.GeneralSecurityException; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.security.web.DefaultRedirectStrategy; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.example.springOAuth.entity.User; | ||
import com.example.springOAuth.service.CredentialService; | ||
import com.example.springOAuth.service.Apps.CalendarService; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/apps") | ||
public class InstalledAppsControlled { | ||
|
||
@Autowired | ||
private CalendarService calendarService; | ||
|
||
@Autowired | ||
private CredentialService credentialService; | ||
|
||
@GetMapping("/{appName}") | ||
public void getMethodName(@PathVariable String appName, HttpServletRequest request, | ||
HttpServletResponse response) throws IOException, GeneralSecurityException { | ||
// String redirect = GoogleMeetLinkGen.createMeetingLink(null, request, | ||
// response); | ||
|
||
String authorizeUrl = calendarService.getAuthorizationUrl(request, response); | ||
var stratigy = new DefaultRedirectStrategy(); | ||
stratigy.sendRedirect(request, response, authorizeUrl); | ||
} | ||
|
||
@GetMapping("/installed") | ||
public ResponseEntity<?> getInstalledApps(@AuthenticationPrincipal User currentUser) { | ||
|
||
var response = credentialService.getInstalledAppHandler(currentUser); | ||
return ResponseEntity.status(HttpStatus.OK).body(response); | ||
} | ||
|
||
} |
Oops, something went wrong.