{"id":4313,"date":"2020-11-25T13:27:08","date_gmt":"2020-11-25T12:27:08","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=4313"},"modified":"2021-05-11T10:59:41","modified_gmt":"2021-05-11T09:59:41","slug":"oauth-2-0","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/oauth-2-0\/","title":{"rendered":"OAuth 2.0"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># request an idtoken + token\ndomain=api.any.com\nclientId=54231\nredirectUri=http:\/\/localhost:4200\/callback # callbackurl\nresponseType=id_token token  # or authcode\nscope=openid profile Custom-API\nnonce=one-time-id-token-id # attribute set on idtoken\nstate=\/abc # any state, returned in callback url\nhttps:\/\/{domain}\/connect\/authorize?client_id={clientId}&redirect_uri={redirectUri}&response_type={responseType}&scope={scope}&nonce={nonce}&state={state}\n\n# to get just an access_token\nresponseType=token\nscope=Custom-API\nhttps:\/\/{domain}\/connect\/authorize?client_id={clientId}&redirect_uri={redirectUri}&response_type={responseType}&scope={scope}\n\n\n<\/pre>\n\n\n\n<p>Source: <a href=\"https:\/\/stackoverflow.com\/a\/42406778\">https:\/\/stackoverflow.com\/a\/42406778<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function genNonce() {\n    const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~'\n    const result = [];\n    window.crypto.getRandomValues(new Uint8Array(32)).forEach(c =>\n        result.push(charset[c % charset.length]));\n    return result.join('');\n}\n\nconsole.info(genNonce());<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/stackoverflow.com\/a\/42406778<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4313","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=4313"}],"version-history":[{"count":3,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4313\/revisions"}],"predecessor-version":[{"id":5057,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4313\/revisions\/5057"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=4313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=4313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=4313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}