Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

javascript - 生成的SHA256哈希不适用于PKCE OAuth2(Generated SHA256 Hash isn't working for PKCE OAuth2)

I am trying to implement PKCE auth flow with oauth2.

(我正在尝试使用oauth2实现PKCE身份验证流程。)

here is what i am doing:

(这是我在做什么:)

  1. Generate random string.

    (生成随机字符串。)

  2. Hash with SHA256 using expo-crypto and then base64encode.

    (使用expo-crypto然后使用base64encode将SHA256哈希。)

  3. proceed with login process.

    (继续登录过程。)

after doing this i get an error stating the code challenge is incorrect.

(完成此操作后,我收到一条错误消息,指出代码挑战不正确。)

https://tonyxu-io.github.io/pkce-generator/

(https://tonyxu-io.github.io/pkce-generator/)

after using this github generator (that uses cryptoJS), i am able to successfully login using the given values.

(使用此github生成器(使用cryptoJS)后,我能够使用给定的值成功登录。)

If i hash the same string using both my generator and the github one it produces different results.

(如果我同时使用生成器和github之一对相同的字符串进行哈希处理,则会产生不同的结果。)

if i use another online hash generator it will yield the same results as my generator.

(如果我使用另一个在线哈希生成器,它将产生与生成器相同的结果。)

What is this github version doing different and how can i achieve this?

(这个github版本有什么不同之处,我如何实现呢?)

i have looked at the source code and copied what i can except for the different crypto libraries.

(我看了看源代码并复制了我可以做的,除了不同的密码库。)

i am using:

(我在用:)

Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, string)

over the github examples:

(在github示例中:)

CryptoJS.SHA256(string)

any help will be greatly appreciated, thanks!

(任何帮助将不胜感激,谢谢!)

  ask by Sam Emily translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...