scotthovestadt / gigya

Gigya JavaScript REST SDK
MIT License
37 stars 62 forks source link

add raw response to handleError + additional API methods #2

Closed ghost closed 8 years ago

ghost commented 9 years ago

We need the raw response (regToken etc...) when an error occured and some additional API methods for a project we are doing. Is it possible to publish this to the public npm registry?

scotthovestadt commented 9 years ago

Hi.

I'll definitely get your commit added to the NPM registry, including the methods that I didn't add to the SDK.

Can you help me understand your use-case for including the raw JSON? The err object should essentially be a parsed version of the JSON at that point, including data on errors that is specific to a method (like validation errors).

There shouldn't be a difference between the JSON and the err object.

ghost commented 9 years ago

Hi Scott,

The reason we want access to the raw JSON is that the parsed error this lib returns doesn't contain all the data we want. I.e. Sometimes an errorCode ( != 0 ) is returned but the raw json contains a gigya user object (with UID, Signature, regToken). We want access to this userData regardless whether an error occured or not. Right now, in case of an errCode all we get is this:

 var e = new Error(json.errorDetails);
e.code = json.errorCode;
e.callId = json.callId;

The JSON returned from the gigya does contain a lot more information that is useful to us. Like in the case of a errorCode 2006001 (Account Pending Registration) Gigya returns the user associated with this account. And we need this for our user login flow. Now all we get is a stripped down error object from this library.

Does that clarify our needs? Thanks!

{ UID: '61cb5a6c9cfa49c1aeae28b00c2b4a79',
  UIDSignature: 'YcH8KxiBYTFsUC8V48zgtJTmc3k=',
  signatureTimestamp: '1422433762',
  loginProvider: 'site',
  isRegistered: false,
  isActive: true,
  isLockedOut: false,
  isVerified: true,
  socialProviders: 'site',
  identities: 
   [ { provider: 'site',
       providerUID: '61cb5a6c9cfa49c1aeae28b00c2b4a79',
       isLoginIdentity: true,
       email: 'ilja.strobbe+blokken1@gmail.com',
       allowsLogin: true,
       isExpiredSession: false,
       lastUpdated: '2015-01-27T13:16:25.803Z',
       lastUpdatedTimestamp: 1422364585803,
       oldestDataUpdated: '2015-01-27T13:16:25.803Z',
       oldestDataUpdatedTimestamp: 1422364585803 } ],
  created: '2015-01-27T13:16:25.771Z',
  createdTimestamp: 1422364585771,
  lastLogin: '2015-01-28T08:29:22.122Z',
  lastLoginTimestamp: 1422433762122,
  lastUpdated: '2015-01-27T13:16:25.803Z',
  lastUpdatedTimestamp: 1422364585803,
  oldestDataUpdated: '2015-01-27T13:16:25.803Z',
  oldestDataUpdatedTimestamp: 1422364585803,
  verified: '2015-01-27T13:17:56.821Z',
  verifiedTimestamp: 1422364676821,
  regToken: 'RT1_stCAQRTU1RLBzY0MjUzMzEBAAAAAADAAQAAVM44ZkMYqJhdrBRFthCYaAKWyn0wRbM4ZIlpWA2qoaDigfnqoyi6rkjrpt2_24UnMQQIIoaUmnkehSiZTbLTZHCBXTGumrpWq0i4c154k2sy0Gf7fi--IT4g1ekeJJWMtKPt_2TXq4kl_fkQyXAdXc0ykZC1Zi0jX4Vxo3z0qMp8jaLdz3XqWX7hE_oNGFYXDN6ouzeS8PfvygiprhwxW3L7bj5Ym27rUemplrOTQHtdAd0C3TSctH5G5Rk92NBM5V1QRif4J6Pzp_gIBEBKxaw8mP6oXMQdrtQP5RZoN-9DCjPLorbcP77D2tP4YDY8W6TL1VlvE7YmSCKgGwJ4qKIxRzwh_wXMpVeYlr9v6oA4BZDv7s_z0FUYBm-ZQDGhH3_1Jtsev0fpB8YdpjkIk7EIZLqkyVju3NW3Xengb4XNp3x26j6ZkFz4CqpLWuwwZxz2am-vqKy1sIu1ibQj1wF4TWrXRqFjNa7HV8DduVcOIo3E49oRvmG-uh29kywDctN-wOxC-Q9k7xcvtI9zWImFcgBisGmAM9cyFdC6QRhVBSo5M9-SW1OD-v5FHGcXhDZnUgo4zB0m4bmyb2FSNBAAAAD7C-ZeWgpFTrB4PFD1TDR4',
  errorDetails: 'Missing required fields for registration: birthYear,country,gender,zip',
  errorMessage: 'Account Pending Registration',
  statusCode: 206,
  errorCode: 206001,
  statusReason: 'Partial Content',
  callId: '20e22af6bea04d28ace574b346243e77' }
scotthovestadt commented 9 years ago

I'll fix it so the error object includes everything. I'll also add the missing methods to the SDK.

ghost commented 8 years ago

Hi scott,

Any news on this issue?

Thanks,

Ilja

scotthovestadt commented 8 years ago

Merged. Thanks!

ghost commented 8 years ago

Thanks! I will remove our fork and depend on node-gigya@0.0.11.

Kind regards,

I

On Thu, Jan 28, 2016 at 11:07 PM, scotthovestadt notifications@github.com wrote:

Merged. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/scotthovestadt/node-gigya/pull/2#issuecomment-176443111 .