{"id":21372274,"url":"https://github.com/rxlabz/ng-sign2g","last_synced_at":"2025-03-16T08:44:08.554Z","repository":{"id":66351570,"uuid":"58860513","full_name":"rxlabz/ng-sign2g","owner":"rxlabz","description":"Angular2 (rc1) Google Sign-In service","archived":false,"fork":false,"pushed_at":"2016-05-18T11:11:44.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T15:08:49.746Z","etag":null,"topics":[],"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/rxlabz.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-05-15T12:31:32.000Z","updated_at":"2016-05-17T20:03:58.000Z","dependencies_parsed_at":"2023-02-24T18:00:58.694Z","dependency_job_id":null,"html_url":"https://github.com/rxlabz/ng-sign2g","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/rxlabz%2Fng-sign2g","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fng-sign2g/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fng-sign2g/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fng-sign2g/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxlabz","download_url":"https://codeload.github.com/rxlabz/ng-sign2g/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846979,"owners_count":20357297,"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":[],"created_at":"2024-11-22T08:18:50.067Z","updated_at":"2025-03-16T08:44:08.535Z","avatar_url":"https://github.com/rxlabz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Sign-In service in Angular 2 App\n\n\u003ca target=\"_blank\" href=\"https://developers.google.com/identity/sign-in/web/sign-in\"\u003eGoogle Sign-In intro\u003c/a\u003e\n\n## Gauth.service\n\nThe Gauth service exposes :\n- **currentProfile$** : an Observable\u003cProfile\u003e which allows to get the user profile.\n- get **isSignedIn()**:boolean\n- **signIn()**\n- **grant(scope:string, offline:boolean = false)** : request additionnal permissions\n- revoke() : cancel all app permissions\n- logout()\n\n### Usage\n\n**Configuration**\n\n- google js api\n```html\n\u003c!-- Index.html --\u003e\n\u003cscript src=\"https://apis.google.com/js/platform.js\"\u003e\u003c/script\u003e\n```\n\n- Injected CLIENT_ID\n\n```typescript\n// app/config.ts\nexport interface Config {\n    client_id:string;\n}\n\nexport let CONFIG:Config = {\n    client_id: 'YOUR_APP_ID_LIKE_0123456789.apps.googleusercontent.com'\n}\n\n// create token used for DI\nexport let APP_CONFIG = new OpaqueToken('app.config');\n\n\n// app/gauth.service.ts\nconstructor(@Inject(APP_CONFIG) private cfg:Config, private http:Http, private ngZone:NgZone) {\n    this.CLIENT_ID = cfg.client_id;\n    this.currentProfile$ = new Observable\u003cProfile\u003e(obs =\u003e this.profileOb$r = obs).share();\n    this.loadApi(this.CLIENT_ID);\n}\n\nloadApi(CLIENT_ID:string) {\n    gapi['load']('auth2', this.onApi.bind(this));\n}\n\n```\n\n\n\nIn this example, the service is injected in Ng2gAuthApp component.\n\n```typescript\n// ng2-auth2.components.ts\nconstructor(public service:GauthService) {}\n\nngOnInit(){\n    this.currentProfile$ = this.service.currentProfile$;\n    this.currentProfile$.subscribe((value)=\u003ethis.profile = value);\n}\n\nonProfile(p:Profile){\n        this.currentProfile = p;\n        this.grantedScopes = p ? p.scope.split(' ') : [];\n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxlabz%2Fng-sign2g","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxlabz%2Fng-sign2g","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxlabz%2Fng-sign2g/lists"}