opened
yanatan16
username_0
From an email I received from Andre:

I have a question regarding Passport-Youtubev3 strategy. It seems to be working however every single time, Google is prompting me to authorize with ‘Have offline access’. The strategy doesn’t seem to allow any additional parameters, however in your code, I found hardcoded following piece of code:

https://github.com/username_0/passport-youtube-v3/blob/master/lib/passport-youtube-v3/strategy.js#L103
```javascript
Strategy.prototype.authorizationParams = function(options) {
  //  test, should be passed through options
  return {
    access_type : 'offline',
    approval_prompt: 'force'
  }
}
```

Should this piece of code be there? Would you have any other ideas?
Offline Access
issue
created
yanatan16
username_0
Yes these authorization parameters cause Google to try to authenticate the offline access ability. My gut feeling is that you'll want offline access, so you can use the access tokens later. 

https://developers.google.com/identity/protocols/OAuth2WebServer#offline

The best fix is probably to actually use the options object passed into that function with a default to the current parameters (for backwards compatibility)
comment
created
yanatan16
username_0
We could just copy the code from https://github.com/jaredhanson/passport-google-oauth/blob/master/lib/passport-google-oauth/oauth2.js#L130
comment
created
RedPointMS
username_1
Thank you Jon
comment
created
yanatan16
username_0
Ok I merged the req and tagged the new version at `1.0.0`. Figured it should be 1.0 anyway. You'll have to update your `package.json` via `npm install passport-youtube-v3@1.0.0 --save`
comment
closed
yanatan16
username_0
issue
created
RedPointMS
username_1
Great! Thanks Jon
comment
created
RedPointMS
username_1
Hi Jon,
I must be missing something, I still have the same problem. It seems that whatever options I set, strategy defaults to 'force' however works fine if I change the hardcoded defaults in your code. Here is how I configure the strategy. What I am doing wrong?

```javascript
passport.use(new YoutubeV3Strategy({
    clientID: "xxxxxxxxxxxxxxxxxxxxxxx",
    clientSecret: "xxxxxxxxxxxxxxxxxxxxx",
    callbackURL: config.SERVER_LOCATION + "/auth/youtube/return",
    approval_prompt: 'auto',
    access_type: 'online',
    scope: ['https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/plus.profile.emails.read']

},
  function (accessToken, refreshToken, profile, done) {...
```
comment
created
yanatan16
username_0
Try 
```javascript
passport.use(new YoutubeV3Strategy({
    clientID: "xxxxxxxxxxxxxxxxxxxxxxx",
    clientSecret: "xxxxxxxxxxxxxxxxxxxxx",
    callbackURL: config.SERVER_LOCATION + "/auth/youtube/return",
    authorizationParams: { 
        approval_prompt: 'auto',
        access_type: 'online'
    },
    scope: ['https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/plus.profile.emails.read']

},
  function (accessToken, refreshToken, profile, done) {...
```
comment
created
bbatliner
username_2
@username_0 I have tried a config (see below) nearly identical to the one you proposed, and `approval_prompt` is still being set to `force`. If I set a breakpoint at the `authorizationParams` method in the Strategy source, `options` has no own properties (not even the other ones like `clientID`).
```
{
  "clientID": "xxxxxxxxxxxxxxxxxxxxxx",
  "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxx",
  "callbackURL": "/path/to/url",
  "profileURL": "https://www.googleapis.com/oauth2/v3/userinfo",
  "authorizationParams": {
    "access_type": "offline",
    "approval_prompt": "auto"
  },
  "scope": ["https://www.googleapis.com/auth/youtube", "email", "profile"]
}
```
comment
created
yanatan16
username_0
@username_2 You are correct. The options that `authorizationParams` gets isn't the same as the `options` passed into `new YoutubeOAuth...`. So I've fixed this in 0b01605
comment