           { url, applicationId, state } = data  if data
 
           state = "&state=#{state}"
-
-          callback null, "#{url}/oauth/authorize?client_id=#{applicationId}&response_type=code#{state}&redirect_uri=#{redirectUri}"
-
-
-      facebook: ->
+          url   = "#{url}/oauth/authorize?"
+          url  += "client_id=#{applicationId}&"
+          url  += "response_type=code#{state}&"
+          url  += "redirect_uri=#{redirectUri}"
+
+          callback null, url
+
+
+    # -- GITHUB PROVIDER --------------------------------------------------8<--
+
+    github    :
+      title   : 'Github OAuth Provider'
+      enabled : false
+      getUrl  : (client, urlOptions, callback) ->
+
+        { clientId } = KONFIG.github
+        { scope, returnUrl } = urlOptions
+        scope = 'user:email'  unless scope
+        redirectUri = "#{redirectUri}?returnUrl=#{returnUrl}"  if returnUrl
+
+        url  = "https://github.com/login/oauth/authorize?"
+        url += "client_id=#{clientId}&"
+        url += "scope=#{scope}&redirect_uri=#{redirectUri}"
+
+        callback null, url
+
+
+    # -- FACEBOOK PROVIDER ------------------------------------------------8<--
+
+    facebook  :
+      title   : 'Facebook OAuth Provider'
+      enabled : false
+      getUrl  : (client, urlOptions, callback) ->
 
         { clientId } = KONFIG.facebook
-        url = "https://facebook.com/dialog/oauth?client_id=#{clientId}&redirect_uri=#{redirectUri}&scope=email"
+        { redirectUri } = urlOptions
+
+        url  = "https://facebook.com/dialog/oauth?"
+        url += "client_id=#{clientId}&"
+        url += "redirect_uri=#{redirectUri}&scope=email"
 
         callback null, url
 
 
-      google: ->
+    # -- GOOGLE PROVIDER --------------------------------------------------8<--
+
+    google    :
+      title   : 'Google OAuth Provider'
+      enabled : false
+      getUrl  : (client, urlOptions, callback) ->
 
         { client_id } = KONFIG.google
+        { redirectUri } = urlOptions
+
         JSession = require './session'
         JSession.one { clientId: client.sessionToken }, (err, session) ->
           return callback err  if err
+
           state = session._id
           url  = 'https://accounts.google.com/o/oauth2/auth?'
           url += 'scope=https://www.google.com/m8/feeds '

          callback null, url


      linkedin: ->

        { client_id } = KONFIG.linkedin
        state = crypto.createHash('md5').update((new Date).toString()).digest('hex')

        url  = 'https://www.linkedin.com/uas/oauth2/authorization?'
        url += 'response_type=code&'

      static        :
        getUrl      : (signature Object, Function)

  NOTSUPPORTEDERR = new KodingError 'OAuth provider is not supported'

  @PROVIDERS =

    # -- GITLAB PROVIDER --------------------------------------------------8<--

    gitlab    :
      title   : 'GitLab OAuth Provider'
      enabled : true
      getUrl  : (client, urlOptions, callback) ->

        checkGroupGitLabSettings = (client, callback) ->

          { sessionToken: clientId, context: { group: slug } } = client

          JSession = require './session'
          JSession.one { clientId }, (err, session) ->
            return callback err  if err
            return callback new KodingError 'Session invalid'  unless session

            JGroup = require './group'
            JGroup.one { slug }, (err, group) ->

              if not err and group and group.config?.gitlab?.enabled

                settings = {
                  url: group.config.gitlab.url
                  applicationId: group.config.gitlab.applicationId
                  state: session._id
                }

                callback null, settings

              else

                callback new KodingError 'Integration is not enabled'

        { returnUrl, redirectUri } = urlOptions
        { applicationId, host, port } = KONFIG.gitlab
        host ?= 'gitlab.com'
        protocol = '//'
