@@ -29,6 +29,9 @@ const oauthPlugin = fp(function (fastify, options, next) {
29
29
if ( typeof options . callbackUri !== 'string' ) {
30
30
return next ( new Error ( 'options.callbackUri should be a string' ) )
31
31
}
32
+ if ( options . callbackUriParams && typeof options . callbackUriParams !== 'object' ) {
33
+ return next ( new Error ( 'options.callbackUriParams should be a object' ) )
34
+ }
32
35
if ( options . generateStateFunction && typeof options . generateStateFunction !== 'function' ) {
33
36
return next ( new Error ( 'options.generateStateFunction should be a function' ) )
34
37
}
@@ -45,19 +48,21 @@ const oauthPlugin = fp(function (fastify, options, next) {
45
48
const name = options . name
46
49
const credentials = options . credentials
47
50
const callbackUri = options . callbackUri
51
+ const callbackUriParams = options . callbackUriParams || { }
48
52
const scope = options . scope
49
53
const generateStateFunction = options . generateStateFunction || defaultGenerateStateFunction
50
54
const checkStateFunction = options . checkStateFunction || defaultCheckStateFunction
51
55
const startRedirectPath = options . startRedirectPath
52
56
53
57
function startRedirectHandler ( request , reply ) {
54
58
const state = generateStateFunction ( )
55
-
56
- const authorizationUri = this [ name ] . authorizationCode . authorizeURL ( {
59
+ const urlOptions = Object . assign ( { } , callbackUriParams , {
57
60
redirect_uri : callbackUri ,
58
61
scope : scope ,
59
62
state : state
60
63
} )
64
+
65
+ const authorizationUri = this [ name ] . authorizationCode . authorizeURL ( urlOptions )
61
66
reply . redirect ( authorizationUri )
62
67
}
63
68
0 commit comments