                          :refresh-token
                          ,(oauth2-token-refresh-token token)
                          :access-response
-                         ,(oauth2-token-access-response token)))
+                         ,(oauth2-token-access-response token)
+                         ))
       (plstore-save plstore)))
   token)
 

          (if (string-match-p "\?" url) "&" "?")
          "access_token=" (oauth2-token-access-token token)))

;; Local variable from `url'
;; defined here to avoid compile warning
(defvar success)

;;;###autoload
(defun oauth2-url-retrieve-synchronously (token url &optional request-method request-data request-extra-headers)
  "Retrieve an URL synchronously using TOKENS to access it.
TOKENS can be obtained with `oauth2-auth'."
  (let (tokens-need-renew)
    (flet ((url-http-handle-authentication (proxy)
                                           (setq tokens-need-renew t)
                                           ;; This is to make `url' think
                                           ;; it's done.
                                           (setq success t)))
      (let ((url-request-method request-method)
            (url-request-data request-data)
            (url-request-extra-headers request-extra-headers)
            (url-buffer))
        (setq url-buffer (url-retrieve-synchronously
                           (oauth2-url-append-access-token token url)))
        (if tokens-need-renew
            (oauth2-url-retrieve-synchronously (oauth2-refresh-access token) url request-method request-data request-extra-headers)
          url-buffer)))))

(provide 'oauth2)


;;; oauth2.el --- OAuth 2.0 Authorization Protocol

;; Copyright (C) 2011-2013 Free Software Foundation, Inc

;; Author: Julien Danjou <julien@danjou.info>
;; Version: 0.10
;; Keywords: comm

;; Modified by Daniel Martins <daniel.tritone@gmail.com>
