Skip to content
This repository has been archived by the owner. It is now read-only.

Attempt to fetch avatar is made after failure to fetch OAuth token #2835

Closed
shane-tomlinson opened this issue Jul 27, 2015 · 3 comments
Closed

Attempt to fetch avatar is made after failure to fetch OAuth token #2835

shane-tomlinson opened this issue Jul 27, 2015 · 3 comments
Assignees

Comments

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Jul 27, 2015

STR:

  1. Apply the diff from below
  2. Visit 123done
  3. Open the developer console, enable network requests
  4. Click "sign in" on 123done
  5. Watch the developer console make the request to the oauth server's /v1/authorization, then the profile server's /v1/avatar

Expected:

  1. No extra request to the profile server. The user isn't authorized.

The proof:

screen shot 2015-07-27 at 14 01 57

The diff:

diff --git a/app/scripts/lib/oauth-client.js b/app/scripts/lib/oauth-client.js
index 09f24bc..2ffd6c0 100644
--- a/app/scripts/lib/oauth-client.js
+++ b/app/scripts/lib/oauth-client.js
@@ -22,6 +22,9 @@ function (xhr, OAuthErrors) {

   OAuthClient.prototype = {
     _request: function (method, endpoint, params) {
+      if (params) {
+        delete params.scope;
+      }
       return this._xhr[method](this._oAuthUrl + endpoint, params || null)
         .fail(function (xhr) {
           var err = OAuthErrors.normalizeXHRError(xhr);

Ref mozilla/fxa-oauth-server#315

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Sep 28, 2015

@shane-tomlinson to check this

@shane-tomlinson
Copy link
Member Author

@shane-tomlinson shane-tomlinson commented Sep 28, 2015

@shane-tomlinson to check if this has been fixed.

@shane-tomlinson
Copy link
Member Author

@shane-tomlinson shane-tomlinson commented Oct 12, 2015

Since mozilla/fxa-oauth-server#315 is fixed, the new diff is:

diff --git a/app/scripts/lib/oauth-client.js b/app/scripts/lib/oauth-client.js
index 09f24bc..65913a4 100644
--- a/app/scripts/lib/oauth-client.js
+++ b/app/scripts/lib/oauth-client.js
@@ -22,6 +22,8 @@ function (xhr, OAuthErrors) {

   OAuthClient.prototype = {
     _request: function (method, endpoint, params) {
+      params = {};
+
       return this._xhr[method](this._oAuthUrl + endpoint, params || null)
         .fail(function (xhr) {
           var err = OAuthErrors.normalizeXHRError(xhr);

The request for the users avatar no longer occurs if the request to /authorization has failed:

screen shot 2015-10-12 at 16 36 49

Closing as fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants