newAuthorizationUrl: Missing required parameter: redirect_uri
RiccardoManzan opened this issue · comments
Riccardo Manzan commented
Environment details
OS type and version: Linux / Ubuntu
Java version: 11
google-oauth-client version(s): 1.31.4
App environment: Micronaut + kotlin
Steps to reproduce
Executing code below generates an url without redirect_uri value
Code example
val flow = GoogleAuthorizationCodeFlow.Builder(
GoogleNetHttpTransport.newTrustedTransport(),
GsonFactory.getDefaultInstance(),
env.get("google-oauth2.google.client-id", String::class.java).get(),
env.get("google-oauth2.google.client-secret", String::class.java).get(),
listOf(DriveScopes.DRIVE)
).setDataStoreFactory(FileDataStoreFactory("datastore"))
.setAccessType("offline")
.build()
val uri = authService.authorizationCodeFlow.newAuthorizationUrl()
.setRedirectUri("/auth/google/callback")
.toURI()
resulting uri:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=############-################################.apps.googleusercontent.com&redirect_uri&response_type=code&scope=https://www.googleapis.com/auth/drive
Riccardo Manzan commented
The problem was browser chaching that was redirecting me to a previous wrong route.
Futhermore you should specify full domain, and not only root relative one ("https://######/auth/google/callback"
).