网站搜索

javascript - 必须同时提供 client_id 和 scope 才能初始化 OAuth

我正在参考 Google Sheets API JavaScript 快速入门,并在使用 gapi.client.init() 时遇到了认证问题。

这是给我带来问题的代码:

// Client ID and API key from the Developer Console var CLIENT_ID = "50m3-cle3nt-1d.apps.googleusercontent.com"; var API_KEY = "AIzaN0tRe4lLyAn4pIk5y"; // Array of API discovery doc URLs for APIs used by the quickstart var DISCOVERY_DOCS = ["https://sheets.googleapis.com/$discovery/rest?version=v4"]; // Authorization scopes required by the API; multiple scopes can be // in

阅读更多 →

javascript - Google Oauth 弹出窗口取消回调

在使用 Google 身份服务(GSI)时,我可以显示一个弹出窗口,要求用户使用他们的 Google 帐号连接。这有相当好的文档,并且使用这段代码效果很好:

const client = window.google.accounts.oauth2.initCodeClient({ client_id: 'CLIENT_ID', scope: 'SCOPE', ux_mode: 'popup', callback: async (response) => { console.log('Response Google', response); }, }); client.requestCode();

阅读更多 →

Javascript 访问 OAuth 2 的 Location 头部的 URL 片段

OAuth 2.0 隐式授权(http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.2)涉及客户端应用程序、浏览器和授权服务器之间的一些有趣的交互。授权服务器向浏览器返回一个带有 Location 头的 HTTP 302 状态码,如下所示:

位置: http://clientapp.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA&state=xyz&token_type=example&expires_in=3600

阅读更多 →

typescript - Ionic OAuth 集成

我在谷歌上查了很多关于 OAuth1.0 与我的 Ionic 应用集成的信息。我没有找到我正在寻找的任何信息。有人可以分享一些示例或想法关于如何集成它吗?我有一个服务器,需要通过 HTTP OAuth 发送请求并以 JSON 数据的形式获取响应。

我在我的应用程序中使用 Ionic 3 和 Angular。

它类似于,例如在 JavaScript 中,我们可以使用 JSOAuth-1.3.6.js 文件来完成上述所有事情。

谢谢 Krishmtech

阅读更多 →

rest - 我如何刷新 OAuth2 令牌?我需要等待令牌过期吗?(Patreon API)

我正在尝试使用 Patreon 的 API 进行 OAuth。我对 OAuth 流程非常陌生,一直在使用 Patreon 的 JavaScript 包来帮助我管理请求。

  • NPM: https://www.npmjs.com/package/patreon
  • Patreon 文档: https://docs.patreon.com/#introduction

到目前为止,我已经能够通过以下方式成功获取令牌:

import * a

阅读更多 →

typescript - 无法向 passport-linkedin-oauth2 声明文件的接口添加属性

我正在尝试为 'passport-linkedin-oauth2' 声明文件中的 'StrategyOption' 接口添加一个属性。它没有声明任何模块或接口,只是导出接口和类

.... export interface StrategyOption { clientID: string; clientSecret: string; callbackURL: string; scopeSeparator?: string; enab

阅读更多 →

c# - 使用 Msal.js 在 React-Typescript 网络应用中调用 .net core API 时 OAuth2 认证失败

我有一个客户端 Typescript React 网络应用,需要与 .NET Core API 通信。在客户端集成了 msal.js。我能够在 AAD 登录,获取用户账户和访问令牌,并将其作为 Bearer 传递给 API 调用。然而,API 级别的身份验证失败了。

在客户端:

config: Msal.Configuration = buildConfiguration({ auth: { clientId: 'c

阅读更多 →

typescript - 从 NbAuthOAuth2Token 获取 Angular 用户数据

我正在这样使用 NbAuthOAuth2Token

this.authService.onTokenChange() .pipe(takeUntil(this.destroy$)) .subscribe((token: NbAuthOAuth2Token) => { this.token = null; if (token && token.isValid()) { this.token = token; } });

在我的登录函数中是这样的

login() { this.authService.authenticate('google') .pipe(takeUntil(this.destroy$)) .subscribe((authResult: NbAuthResult) => { }); }

如何获取用户数据?我正在使用

阅读更多 →

typescript - Angular-oauth2-oidc 清除 localStorage 中过期的令牌信息

我正在尝试在一个 Angular 前端项目中自定义 angular-oauth2-oidc 库的 PKCE 流程。

我也在使用 localStorage 为这个库存储 token 等信息,但我似乎找不到方法清除 localStorage 中过期的 token 信息。

这难道不应该自动完成吗?

阅读更多 →

TypeScript - 使用 Discord OAuth 和 Cors 的 Angular 拦截器

我正在尝试使用 Discord 设置 OAuth2 登录,我已经将获取 OAuth 代码的 URL 设置为我 'environment.ts' 文件中的环境变量,所以问题不是出在 URL 拼写错误上。

href 锚点链接工作正常,然而在调用服务方法并且(据我理解)在其中添加拦截器时,我每次都会得到这个错误(授权 URL 已简化)

Access to XMLHttpRequest at 'https://discord.com/oauth2/authorize.....' (redirected from 'https://discord.com/api/oauth2/authorize?....') from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

拦截器代码:

阅读更多 →