Git Product home page Git Product logo

fusionauth-node-client's Introduction

FusionAuth Node.js Client

semver 2.0.0 compliant npm


Deprecation Warning

This repository has been deprecated in favor of the fusionauth-typescript-client. You can just change your dependency and should have no problems using it with node as the package is still javascript but with additional type information. If you run into problems then let us know over there.

We will continue to publish this package for several more versions before we archive it and fully deprecate its use. Please make arrangements to migrate to the typescript client soon.


Details

If you're integrating FusionAuth with a Node application, this library will speed up your development time.

For additional information and documentation on FusionAuth refer to https://fusionauth.io.

Installation To install fusionauth-node-client, use npm

npm install @fusionauth/node-client

Refer to the FusionAuth API documentation to for request and response formats.

Upgrade Policy

This library is built automatically to keep track of the FusionAuth API, and may also receive updates with bug fixes, security patches, tests, code samples, or documentation changes.

These releases may also update dependencies, language engines, and operating systems, as we'll follow the deprecation and sunsetting policies of the underlying technologies that it uses.

This means that after a dependency (e.g. language, framework, or operating system) is deprecated by its maintainer, this library will also be deprecated by us, and will eventually be updated to use a newer version.

fusionauth-node-client's People

Contributors

fusionandy avatar matthew-altman avatar mooreds avatar robfusion avatar robotdan avatar trex avatar tyduptyler13 avatar vcampitelli avatar voidmain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fusionauth-node-client's Issues

Unable to search users using queryString

I am using the following code to get all users. It works with the Java client but is giving the following error

{ code: '[invalid]', api_1 | message: 'You must specify either the [ids], [queryString], [email] or [username] property for a GET request.' }

    let requestJSON = {}
    requestJSON.queryString = "*";
    client.searchUsersByQueryString(requestJSON).then(handleResponse).catch(handleResponse);
  
    function handleResponse (clientResponse) {
        console.log(clientResponse.errorResponse.generalErrors[0]);
        res.setHeader('Content-Type', 'application/json');
        res.json({result: clientResponse.successResponse.user});
    }

Also for some reason, it is assuming this to be a GET Request.

Error after updating from 1.11.0 to 1.12.1

I'm seeing this error after updating from 1.11.0 to 1.12.1 today.

this._startAnonymous.authorization is not a function

The lib instantiates fine but throws the error when trying to call retrieveTenant()

I checked the docs to see if anything else had changed, but I'm not seeing anything.

ReferenceError: this_startAnonymous is not defined

I'm using the latest 1.12.0 version of this client library and I'm unable to perform requests with it.

Seems that there is a typo at https://github.com/FusionAuth/fusionauth-node-client/blame/94e576fea5fa1e186165dfb8954bb738d455f5fd/lib/FusionAuthClient.js#L3501

ReferenceError: this_startAnonymous is not defined
    at FusionAuthClient._start (/media/mihail/Workspace1/git/cli/node_modules/@fusionauth/node-client/lib/FusionAuthClient.js:3501:5)
    at Promise (/media/mihail/Workspace1/git/cli/node_modules/@fusionauth/node-client/lib/FusionAuthClient.js:1081:12)
    at tryCallTwo (/media/mihail/Workspace1/git/cli/node_modules/promise/lib/core.js:45:5)
    at doResolve (/media/mihail/Workspace1/git/cli/node_modules/promise/lib/core.js:200:13)
    at new Promise (/media/mihail/Workspace1/git/cli/node_modules/promise/lib/core.js:66:3)
    at FusionAuthClient.importKey (/media/mihail/Workspace1/git/cli/node_modules/@fusionauth/node-client/lib/FusionAuthClient.js:1080:12)

this_startAnonymous -> this._startAnonymous

Can't access refresh token

I can't access the refresh as it's sent in the headers, tried both the login() and retrieveRefreshTokens() methods, as the refresh token is always sent in the header.

I think for functions involving the refresh token, the API client should append the refresh token to the response body

setinterval(...).unref is not a function

JWTManager.js?8e3b:63 Uncaught TypeError: setInterval(...).unref is not a function
at eval (JWTManager.js?8e3b:63)
at Object../node_modules/@fusionauth/node-client/lib/JWTManager.js (build.js:1280)
at webpack_require (build.js:712)
at fn (build.js:95)
at eval (index.js?c2d1:10)
at Object../node_modules/@fusionauth/node-client/index.js (build.js:1244)
at webpack_require (build.js:712)
at fn (build.js:95)
at eval (LoginPage.vue?188a:47)
at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/eslint-loader/index.js!./example/src/pages/pages/LoginPage.vue?vue&type=script&lang=js (build.js:1410)

[email protected]
[email protected]
VueJs

FusionAuthClient.login method not returning JWT cookie headers

Posting directly to /api/login with the same JSON body responds with the correct Set-Cookie header for a JWT access token.

Through this API (FusionAuthClient.login(jsonObj)) the exact same body is returned, but no Set-Cookie header. Same server, same application, same authentication etc etc.

Unable to delete a tenant that has users

I'm currently using the @fusionauth/node-client version 1.7.3 and I'm unable to delete a tenant that has registered users.

When I call the following error is thrown when the deleteTenant method is called:

{ 
 statusCode: 500,
 errorResponse: { 
   generalErrors: [{ 
     code: '[Exception]',
     message: 'FusionAuth encountered an unexpected error. Please contact support for assistance.' 
    }] 
  },
  successResponse: null,
  exception: null 
}

For more details I've took a look at the database (postgres-10.6) and fusionauth-app (1.7.2) docker services logs:

database_1       | 2019-07-15 12:43:41.371 UTC [36] ERROR:  update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
database_1       | 2019-07-15 12:43:41.371 UTC [36] DETAIL:  Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
database_1       | 2019-07-15 12:43:41.371 UTC [36] STATEMENT:  DELETE FROM tenants WHERE id = $1
fusionauth_1     | Jul 15, 2019 12:43:41.376 PM ERROR io.fusionauth.app.primeframework.error.ExceptionExceptionHandler - An unhandled exception was thrown
fusionauth_1     | org.apache.ibatis.exceptions.PersistenceException:
fusionauth_1     | ### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
fusionauth_1     |   Detail: Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
fusionauth_1     | ### The error may involve defaultParameterMap
fusionauth_1     | ### The error occurred while setting parameters
fusionauth_1     | ### SQL: DELETE FROM tenants WHERE id = ?
fusionauth_1     | ### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
fusionauth_1     |   Detail: Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
fusionauth_1     | 	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
fusionauth_1     | 	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
fusionauth_1     | 	at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:213)
fusionauth_1     | 	at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
...

Please note that deleting the tenant via dashboard works flawlessly.

400 response from Complete Google Login API

Hope you all are doing good. I am implementing a social sign-in flow using Google and want to use FusionAuth Complete Google Login API. I followed that document where it is written that,

This API is intended to be used if you want to build your own login page and you have added the Google login button to your own login page and you then need to complete the login with FusionAuth.

For example, if you built your own login page, you could add a "Login with Google" button and complete the Google authentication. When you complete the Google authentication you will have been returned a token or code from Google. Using this API you can pass that token or code to FusionAuth and we will complete the login workflow and reconcile the user to FusionAuth.

But whenever I hit that API with the token provided by Google from the NestJS project, it gives me 400 error response.

code: [ExternalAuthenticationException]GoogleTokenInfo
message: A request to the Google Token Info API has failed. Unable to complete this login request.

From the FusionAuth debug log,

Request to the [https://www.googleapis.com/oauth2/v3/tokeninfo] endpoint failed. Status code [400].

Error response is 
{
  "error_description" : "Invalid Value"
}

But if I curl the token received from the google, it tells me the token is valid,

curl "https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=ya29.A0ARrdaM-mIQDJ645tNQv5ifTZ7QxfhTNK_gE4pYsukhoU_EVt7ejSjW6H22fYW5ICgx89IXXXXXXXXXXXXXXXXXXXWBhUUhclMJx2p3xcpekxKjs1B2"


{
  "azp": "939548483275-vnakrrcv6c7t2fmdcji8nbcom6dn52or.apps.googleusercontent.com",
  "aud": "939548483275-vnakrrcv6c7t2fmdcji8nbcom6dn52or.apps.googleusercontent.com",
  "sub": "116524708611814561365",
  "scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid",
  "exp": "1646312085",
  "expires_in": "3425",
  "email": "[email protected]",
  "email_verified": "true",
  "access_type": "online"
}

From NestJS I called that request as follows,

const response = await this.fusionClient.identityProviderLogin({
        applicationId: "XXXXXX",
        data: {
          token: req.user.accessToken,
        },
        identityProviderId: "82339786-3dff-42a6-aac6-1f1ceecb6c46",
      });

I have ensured that req.user.accessToken should contain the access token and its type should be string. I have already curl that google tokeninfo api via POST method, in order to check whether its giving me the same response or not, and it just gave me the same aforementioned response.

Could you guys please help me out in this case whether I am missing something in Fusion Auth configuration? BTW I have successfully configured Login with Google and Login with Facebook social logins with FusionAuth that FusionAuth provided via its login form.

Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.