This file contains hidden or 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
package com.tutorial.googleeoauth.repository | |
import com.tutorial.googleeoauth.domain.GoogleCredentialDetails | |
import org.springframework.data.domain.Page | |
import org.springframework.data.domain.Pageable | |
import org.springframework.data.jpa.repository.JpaRepository | |
/** | |
* Repository for {@link GoogleCredentialDetails}. Represents credentials of Google's | |
* OAuth authentication and authorization process. |
This file contains hidden or 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
package com.tutorial.googleeoauth | |
import com.google.api.client.auth.oauth2.StoredCredential | |
import com.google.api.client.util.store.AbstractDataStore | |
import com.google.api.client.util.store.DataStore | |
import com.tutorial.googleeoauth.domain.GoogleCredentialDetails | |
import com.tutorial.googleeoauth.exception.ResourceNotFoundException | |
import com.tutorial.googleeoauth.repository.GoogleCredentialDetailsRepository | |
import java.util.stream.Collectors |
This file contains hidden or 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
package com.tutorial.googleeoauth | |
import com.google.api.client.util.store.DataStore | |
import com.google.api.client.util.store.DataStoreFactory | |
import com.tutorial.googleeoauth.repository.GoogleCredentialDetailsRepository | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.stereotype.Component | |
/** | |
* Data store factory class required for implementing a custom data store to store credential |
This file contains hidden or 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
package com.tutorial.googleeoauth.domain | |
import com.google.api.client.auth.oauth2.StoredCredential | |
import groovy.transform.CompileStatic | |
import javax.persistence.Entity | |
import javax.validation.constraints.NotNull | |
import java.time.LocalDateTime | |
/** |
This file contains hidden or 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
implementation 'com.google.auth:google-auth-library-oauth2-http:0.17.1' | |
implementation ('com.google.oauth-client:google-oauth-client-jetty:1.28.0') { | |
exclude group: 'org.mortbay.jetty', module: 'servlet-api' // had to exclude this but will depend on the rest of your dependencies | |
} |
This file contains hidden or 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
import grails.artefact.Enhances | |
import org.grails.core.artefact.ControllerArtefactHandler | |
@Enhances(ControllerArtefactHandler.TYPE) //you can do the same with ServiceArtefactHandler.TYPE | |
trait ExceptionHandler { | |
def handleControllerError(Exception e) { | |
response.status = 400 | |
render ApiError.unknownError as JSON | |
} |
This file contains hidden or 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
class RandomController implements ExceptionHandler { | |
} |
This file contains hidden or 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
import grails.converters.JSON | |
import com.mari.ApiError | |
trait ExceptionHandler { | |
def handleControllerError(Exception e) { | |
response.status = 400 | |
render ApiError.unknownError as JSON | |
} | |
} |