 
 
   @saveTokens = (client, provider, credentials, callback) ->
+    JSession = require './session'
     JSession.one { clientId: client.sessionToken }, (err, session) ->
       return callback err  if err
       return callback new KodingError 'Session not found'  unless session


        callback null, url


    }[provider]?()


  @getUrl = secure (client, options, callback) ->

    { provider } = options

    if redirectUri = KONFIG[provider].redirectUri or KONFIG[provider].redirect_uri
      redirectUri  = @prependGroupName redirectUri, client.context.group

        getUrl      : (signature Object, Function)



  getUrlFor = (options, urlOptions, callback) ->

    { client, provider, redirectUri } = options

    ({

      github: ->

        { clientId } = KONFIG.github
        { scope, returnUrl } = urlOptions
        scope = 'user:email'  unless scope
        redirectUri = "#{redirectUri}?returnUrl=#{returnUrl}"  if returnUrl
        url = "https://github.com/login/oauth/authorize?client_id=#{clientId}&scope=#{scope}&redirect_uri=#{redirectUri}"
