{"id":19665538,"url":"https://github.com/geeklearningio/gl-ionic-oauth-client","last_synced_at":"2026-05-10T20:44:18.098Z","repository":{"id":69663294,"uuid":"62398963","full_name":"geeklearningio/gl-ionic-oauth-client","owner":"geeklearningio","description":"Authentification module for Ionic","archived":false,"fork":false,"pushed_at":"2017-10-19T13:28:34.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-10T02:33:53.005Z","etag":null,"topics":["authentication","ionic","oauth","plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geeklearningio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-01T14:34:22.000Z","updated_at":"2017-08-11T14:15:42.000Z","dependencies_parsed_at":"2023-06-29T10:01:06.132Z","dependency_job_id":null,"html_url":"https://github.com/geeklearningio/gl-ionic-oauth-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeklearningio%2Fgl-ionic-oauth-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeklearningio%2Fgl-ionic-oauth-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeklearningio%2Fgl-ionic-oauth-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeklearningio%2Fgl-ionic-oauth-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geeklearningio","download_url":"https://codeload.github.com/geeklearningio/gl-ionic-oauth-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240974877,"owners_count":19887336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","ionic","oauth","plugin"],"created_at":"2024-11-11T16:23:22.337Z","updated_at":"2026-05-10T20:44:18.039Z","avatar_url":"https://github.com/geeklearningio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\nThis is an OAuth npm component, which can used in any Ionic framework's application.\nThere is a test app using this OAuth Service to show how to configure and use it.\n\n# Requirements\n- npm\n- ionic\n- [cordova-plugin-inappbrowser](https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/)\n\n# How to configure\n1) In your project folder, install this plugin using npm\n`npm install git+https://git@github.com/geeklearningio/gl-ionic-oauth-client.git --save`\n\n2) You can use the Typescript (`package/src/AuthenticationService.ts`) or the Javascript ((`package/dist/AuthenticationService.js`)) version of the Service.\n\n3) In your application's main module, inject the dependency `gl-ionic-oauth-client` in order to use the Service.\n```\nangular.module('mainModuleName', ['ionic', 'gl-ionic-oauth-client']){\n//\n}\n```\n\n# How to use\n\n## Init\nInit the service by calling the `init` function, giving the client-id and the url of your Login function of your OAuth server.\n```\n// TODO: change these fields to connect to your oAuth server\nvar clientId = \"clientId\";\nvar oauthUrl = \"https://your-oauth-server/Login\";\n\nthis.authenticationService.init(clientId, oauthUrl);\n```\n## OAuth call\nCall the `handleOAuth` function with these params :\n- Your API function that will give you the accessToken by getting the accessCode.\n- the url and state of the page you want to go to when the Authentication has succeeded. (The url is needed to work in the web version of your app).\n- the state to redirect to with the accessCode as a Query param.\n````\nvar apiOAuthFunction = this.fakeAPIService.connect.bind(this.fakeAPIService);\nvar oauthRedirectState = 'main';\nvar successRedirectUrlAndState = {\n    state: 'success',\n    url: 'success'\n};\nthis.authenticationService.handleOAuth(apiOAuthFunction, successRedirectUrlAndState, oauthRedirectUrl);\n````\n\n# Useful functions and events\n\n## Success and Error events\nThis OAuth Service broadcasts success and error events to let you handle these properly:\n```\nthis.$rootScope.$on(AuthenticationService.AuthenticationOAuthError, () =\u003e {\n    console.log('connecton error');\n});\n```\n```\nthis.$rootScope.$on(AuthenticationService.AuthenticationOAuthSuccess, () =\u003e {\n    console.log('connecton succeeded');\n});\n```\n\n## Logout function\nYou can disconnect the user of your application by calling the `logout` function that will clear the accessToken and the refreshToken of your cache. The parameter is the state to go to after the logout.\n```\nthis.authenticationService.logout('main');\n```\n\n## Refresh Token function\nYou can refresh your accessToken by using the refreshToken given by your API at your first login. Just call the `refreshTokenOrLogout` that will refresh your token or logout if it fails doing so. You will have to pass it 2 params:\n- the refreshToken function of your API.\n- the state to got to after the logout.\n```\nvar apiRefreshTokenFunction = this.fakeAPIService.refreshToken.bind(this.fakeAPIService);\nthis.authenticationService.refreshTokenOrLogout(apiRefreshTokenFunction, 'main').then((result) =\u003e {\n    this.newAccessToken = result.data.content.accessToken;\n});\n```\n\n## How to use the test app\nthe test app does not have the package as a dependency. It allows you to make changes directly to the package and use it in your test app.\n\nYou need to link the package locally.\nAt the root of the project (containing the `package` and the `test-app` folders) type this in the terminal:\n```\nnpm link\n```\nIt will add `gl-ionic-oauth-client` as a global npm module.\n\nThen go in the test-app folder and type this:\n```\nnpm link gl-ionic-oauth-client\n```\nIt will link it to the test-app.\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeklearningio%2Fgl-ionic-oauth-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeeklearningio%2Fgl-ionic-oauth-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeklearningio%2Fgl-ionic-oauth-client/lists"}