如何解决如何在我的 Angular 网络应用上实现 RazerID 登录?
好的,所以我正在尝试在我的 Angular Web 应用程序中实现 RazerID 登录。根据 Razer 的文档,据我所知,我应该使用 GET 方法。我可能理解错误。所以这就是我目前正在尝试这样做的方式。我什至不确定这是否是正确的做法,如果这完全错误,我很抱歉。第一个片段是我的 app.component.ts。
import { Component,OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
export class User {
constructor(
public openid: string,public email: string,public profile: string
) {}
}
@Component({
selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
user: User[] | undefined;
constructor( private httpClient: HttpClient) {}
ngOnInit(): void {
this.getUser();
}
getUser () {
this.httpClient.get<any>('https://oauth2.razer.com/authorize_openid?response_type=token&scope=openid+email+profile&client_id={CLIENT_ID}&state=xyz&redirect_uri=http://localhost:4200').subscribe(
response => {
console.log(response);
this.user = response;
try {
} catch(error) {
console.log('Error happened here!')
console.error(error)
}
}
);
}
}
(不要介意 CLIENT_ID,我特意删除了这里的代码。) 所以无论如何我得到的这段代码是控制台中的一个错误。
ERROR
HttpErrorResponse {headers: HttpHeaders,status: 200,statusText: "OK",url: "https://razerid.razer.com/?theme=light&redirect=ht…p%3A%2F%2Flocalhost%3A4200&client_id=openidclient",ok: false,…}
error:
error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.onLoad (http://localhost:4200/vendor.js:70850:51) at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:9766:31) at Object.onInvokeTask (http://localhost:4200/vendor.js:47590:33) at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:9765:60) at Zone.runTask (http://localhost:4200/polyfills.js:9538:47) at ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:9847:34) at invokeTask (http://localhost:4200/polyfills.js:10960:14) at XMLHttpRequest.globalZoneAwareCallback (http://localhost:4200/polyfills.js:10997:21)
text: "<!doctype html><html id="wcri-html" dir="auto" lang="en"><head><Meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><Meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1"/><Meta name="apple-mobile-web-app-capable" content="yes"/><Meta name="theme-color" content="#000000"/><Meta name="robots" content="__Meta_ROBOTS__"/><Meta name="description" content="The Official Razer ID page for Razer account creation,product warranty registration,and sign-in purposes."/><link rel="manifest" href="/manifest.json"/><title>Razer ID</title><link href="https://razerid-assets.razerzone.com/static/css/main.0549ce90.chunk.css" rel="stylesheet"></head><body style="background-color:#222"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>var rzrIsReloadingPage = false;↵ function rzrWindowOnError(e) {↵ var lastForceReload = window.localStorage.getItem('rzrLastForceReload');↵ if (lastForceReload) {↵ try {↵ lastForceReload = JSON.parse(lastForceReload);↵ } catch (err) {↵ lastForceReload = null;↵ }↵ }↵ if (↵ e &&↵ e.target &&↵ e.target.src &&↵ e.target.src.indexOf(↵ `${window.location.origin}${window.location.pathname}static/`↵ ) > -1 &&↵ !rzrIsReloadingPage &&↵ (!lastForceReload || Date.Now() - lastForceReload > 60000)↵ ) {↵ rzrIsReloadingPage = true;↵ window.localStorage.setItem('rzrLastForceReload',Date.Now());↵ // Remove faulty service worker and reload the page without cache↵ if (typeof navigator.serviceWorker === 'object') {↵ navigator.serviceWorker.getRegistration().then(function(reg) {↵ if (reg) {↵ reg.unregister().then(function() {↵ window.location.reload(true);↵ });↵ } else {↵ window.location.reload(true);↵ }↵ });↵ } else {↵ window.location.reload(true);↵ }↵ }↵ }↵ window.addEventListener('error',rzrWindowOnError,true);↵ setTimeout(function() {↵ window.removeEventListener('error',rzrWindowOnError);↵ },60000);</script><script>!function(u){function e(e){for(var r,t,n=e[0],a=e[1],o=e[2],c=0,f=[];c<n.length;c++)t=n[c],d[t]&&f.push(d[t][0]),d[t]=0;for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(u[r]=a[r]);for(s&&s(e);f.length;)f.shift()();return l.push.apply(l,o||[]),i()}function i(){for(var e,r=0;r<l.length;r++){for(var t=l[r],n=!0,a=1;a<t.length;a++){var o=t[a];0!==d[o]&&(n=!1)}n&&(l.splice(r--,1),e=p(p.s=t[0]))}return e}var t={},d={6:0},l=[];function p(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return u[e].call(r.exports,r,r.exports,p),r.l=!0,r.exports}p.e=function(o){var e=[],t=d[o];if(0!==t)if(t)e.push(t[2]);else{var r=new Promise(function(e,r){t=d[o]=[e,r]});e.push(t[2]=r);var n,c=document.createElement("script");c.charset="utf-8",c.timeout=120,p.nc&&c.setAttribute("nonce",p.nc),c.src="https://razerid-assets.razerzone.com/static/js/"+({}[o]||o)+"."+{0:"08b037f2",1:"0e584d06",2:"ad9dc9ce",3:"946e9e24",4:"fa9d33cf",8:"913fa75e",9:"a22d090e",10:"302d940d",11:"1ef9f74d",12:"80c73963",13:"95ab969f",14:"c8a1ebc7",15:"e9b0c997",16:"272ced79",17:"648aa24b",18:"2c830145",19:"01a731c3",20:"41becc61",21:"b1da1670",22:"be5b8102",23:"cda32e88",24:"a968e59c",25:"c08e677a",26:"4c02a4a5",27:"4612b36e",28:"2601de1d",29:"7ca68750",30:"222120ae",31:"0390dc04",32:"a3067eae",33:"0e35ad94",34:"f432ed1a",35:"45f4551a",36:"dd4469eb",37:"94fedb44",38:"01466662",39:"2e506f99",40:"a1dc2520",41:"1408a316",42:"7b9b7c8c",43:"1b0e04af",44:"78a50e17",45:"a6f5a2ef",46:"c839195f",47:"fd762dba",48:"8eb7fa18",49:"d4b309ac",50:"4ede472a",51:"d3622315",52:"973a8e75"}[o]+".chunk.js",n=function(e){c.onerror=c.onload=null,clearTimeout(f);var r=d[o];if(0!==r){if(r){var t=e&&("load"===e.type?"missing":e.type),n=e&&e.target&&e.target.src,a=new Error("Loading chunk "+o+" Failed.\n("+t+": "+n+")");a.type=t,a.request=n,r[1](a)}d[o]=void 0}};var f=setTimeout(function(){n({type:"timeout",target:c})},12e4);c.onerror=c.onload=n,document.head.appendChild(c)}return Promise.all(e)},p.m=u,p.c=t,p.d=function(e,t){p.o(e,r)||Object.defineProperty(e,{enumerable:!0,get:t})},p.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.t=function(r,e){if(1&e&&(r=p(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(p.r(t),Object.defineProperty(t,"default",value:r}),2&e&&"string"!=typeof r)for(var n in r)p.d(t,n,function(e){return r[e]}.bind(null,n));return t},p.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(r,"a",r),r},p.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},p.p="/",p.oe=function(e){throw console.error(e),e};var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var a=0;a<r.length;a++)e(r[a]);var s=n;i()}([])</script><script src="https://razerid-assets.razerzone.com/static/js/7.295a1d12.chunk.js"></script><script src="https://razerid-assets.razerzone.com/static/js/main.aac17e00.chunk.js"></script></body></html>"
__proto__: Object
headers: HttpHeaders
lazyInit: () => {…}
lazyUpdate: null
normalizednames: Map(0) {}
__proto__: Object
message: "Http failure during parsing for https://razerid.razer.com/?theme=light&redirect=https%3A%2F%2Foauth2.razer.com%2Fauthorize_openid%3Fresponse_type%3Dtoken%26scope%3Dopenid%2Bemail%2Bprofile%26client_id%3D9d5a9d220e8459a4964dafaf38015aed674d1ed1%26state%3Dxyz%26redirect_uri%3Dhttp%3A%2F%2Flocalhost%3A4200&client_id=openidclient"
name: "HttpErrorResponse"
ok: false
status: 200
statusText: "OK"
url: "https://razerid.razer.com/?theme=light&redirect=https%3A%2F%2Foauth2.razer.com%2Fauthorize_openid%3Fresponse_type%3Dtoken%26scope%3Dopenid%2Bemail%2Bprofile%26client_id%3CLIENT_ID1%26state%3Dxyz%26redirect_uri%3Dhttp%3A%2F%2Flocalhost%3A4200&client_id=openidclient"
__proto__: HttpResponseBase
所以我所希望的基本上就像社交登录。这样的例子很难找到,但这个网站:mogul.gg 有。提前致谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。