{"action":"created","comment":{"url":"https://api.github.com/repos/okta/okta.github.io/pulls/comments/61510564","id":61510564,"diff_hunk":"@@ -4,138 +4,171 @@ title: Okta Auth SDK\n excerpt: Easily add Okta capabilities to your website.\n ---\n \n-> This SDK is currently in **Beta** status.\n-\n # Introduction\n \n-The Okta Sign-In SDK builds on top of our [Authentication APIs](), allowing \n-you to create a custom login experience using JavaScript. This includes \n-a traditional Okta authentication flow with MFA or Social Auth.\n+The Okta Auth SDK builds on top of our [Authentication API](/docs/api/resources/authn.html); enabling you to create a custom login experience using JavaScript.\n \n # Prerequisites\n \n-- An Okta org - Register for [Okta Developer Edition](https://www.okta.com/developer/signup/) if you don't have an existing org\n-- [CORS enabled for your domain](/docs/api/getting_started/enabling_cors.html)\n+- Use an existing Okta org or register for [Okta Developer Edition](https://www.okta.com/developer/signup/)\n+- [Add CORS to your domain in Okta](/docs/api/getting_started/enabling_cors.html)\n \n # Installation\n \n Include the following script in your page:\n \n ~~~ html\n-<script src=\"OktaAuth.js\" type=\"text/javascript\"></script>\n+<script src=\"https://ok1static.oktacdn.com/assets/js/sdk/okta-auth-sdk-1.0.0.min.js\" type=\"text/javascript\"></script>\n ~~~\n \n ## Authentication Flow\n \n-The goal of an authentication flow is setting an Okta cookie. Simple!\n+The goal of an authentication flow is setting an Okta cookie. We use [A+ Promises](https://promisesaplus.com/). If you want an introduction to Promises, [read this](http://documentup.com/kriskowal/q/). Here's an example of how we use Promises:\n \n ~~~ javascript\n var authClient = new OktaAuth({url: 'https://your-org.okta.com'});\n authClient.signIn({\n   username: 'some-username',\n   password: 'some-password'\n })\n-.then(function(transaction) {\n+.then(function(transaction) { // On success\n   switch(transaction.status) {\n     \n     case 'SUCCESS':\n-      authClient.session.setCookieAndRedirect(transaction.sessionToken);\n+      authClient.session.setCookieAndRedirect(transaction.sessionToken); // Sets a cookie on redirect\n       break;\n \n     default:\n       throw 'We cannot handle the ' + transaction.status + ' status';\n   }\n })\n-.fail(function(err) {\n+.fail(function(err) { // On failure\n   console.error(err);\n });\n ~~~\n \n-As you can see, we use [A+ Promises](https://promisesaplus.com/) (via\n-[Q](https://github.com/kriskowal/q)). This allows us to handle asynchronous \n-actions, like HTTP requests, in a way that appears more synchronous.\n-\n-Most methods during an authentication flow will resolve `then` with a \n-[Transaction](#transactions).\n-\n-A `fail` will resolve with one of several [Errors](#errors).\n-\n ## Transactions\n \n-Providing only a username and password may not be sufficient to obtain a\n-sessionToken. You may need to reset a password, enroll in MFA, or verify your\n-existing MFA. To track your progression through these states, we use a\n-transaction. The possible states, their definitions, and their flow can be found\n-in our [Authentication API documentation](/docs/api/resources/authn.html#transaction-state).\n-\n-Here is a list of the states and their possible methods:\n-\n-> Methods listed for certain states may only be available in certain scenarios\n-\n-> `stateToken` is never required as a parameter\n+Providing only a username and password may not be sufficient to obtain a cookie. You may need to reset a password, enroll in multifactor authentication (MFA), or verify your existing MFA. To track your progression through these states, we use a transaction. The possible states, their definitions, and their flow can be found in our [Authentication API documentation](/docs/api/resources/authn.html#transaction-state). The following are collections of transaction states and their possible methods.\n \n-> All transactions have:\n+> Keep in mind:\n >\n-> * `status` - Matches the transaction's state\n-> * `data` - The response body as an object\n-\n-### SUCCESS\n+> * Methods listed for a state are not always guaranteed to be available\n+>\n+> * `stateToken` is never required as a parameter\n+>\n+> * All transactions have a `data` attribute that contains the response body as an object","path":"_source/docs/guides/okta_auth_sdk.md","position":94,"original_position":94,"commit_id":"da58ffdc04592a424d9d2f1514ef3ece040994ca","original_commit_id":"da58ffdc04592a424d9d2f1514ef3ece040994ca","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"will fix!","created_at":"2016-04-28T22:06:22Z","updated_at":"2016-04-28T22:06:22Z","html_url":"https://github.com/okta/okta.github.io/pull/226#discussion_r61510564","pull_request_url":"https://api.github.com/repos/okta/okta.github.io/pulls/226","_links":{"self":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/comments/61510564"},"html":{"href":"https://github.com/okta/okta.github.io/pull/226#discussion_r61510564"},"pull_request":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/226"}}},"pull_request":{"url":"https://api.github.com/repos/okta/okta.github.io/pulls/226","id":68121334,"html_url":"https://github.com/okta/okta.github.io/pull/226","diff_url":"https://github.com/okta/okta.github.io/pull/226.diff","patch_url":"https://github.com/okta/okta.github.io/pull/226.patch","issue_url":"https://api.github.com/repos/okta/okta.github.io/issues/226","number":226,"state":"open","locked":false,"title":"Added more docs for okta-auth-js","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"@mystiberry-okta @joelfranusic-okta @raphaellondner-okta @slee-okta @karlmcguinness-okta @rchild-okta @larsjohansen-okta @stsai-okta \r\n\r\nThis will serve as our docs for [the okta-auth-js sdk](https://github.com/okta/okta-auth-js).","created_at":"2016-04-27T20:42:48Z","updated_at":"2016-04-28T22:06:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71b390126aefe18c2ebaa0b638a773777119e065","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/okta/okta.github.io/pulls/226/commits","review_comments_url":"https://api.github.com/repos/okta/okta.github.io/pulls/226/comments","review_comment_url":"https://api.github.com/repos/okta/okta.github.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/okta/okta.github.io/issues/226/comments","statuses_url":"https://api.github.com/repos/okta/okta.github.io/statuses/da58ffdc04592a424d9d2f1514ef3ece040994ca","head":{"label":"okta:lb-88076-okta-auth-js-docs","ref":"lb-88076-okta-auth-js-docs","sha":"da58ffdc04592a424d9d2f1514ef3ece040994ca","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":10953058,"name":"okta.github.io","full_name":"okta/okta.github.io","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta.github.io","description":"Okta Identity Platform API Docs and Developer Home","fork":false,"url":"https://api.github.com/repos/okta/okta.github.io","forks_url":"https://api.github.com/repos/okta/okta.github.io/forks","keys_url":"https://api.github.com/repos/okta/okta.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta.github.io/teams","hooks_url":"https://api.github.com/repos/okta/okta.github.io/hooks","issue_events_url":"https://api.github.com/repos/okta/okta.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta.github.io/events","assignees_url":"https://api.github.com/repos/okta/okta.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta.github.io/tags","blobs_url":"https://api.github.com/repos/okta/okta.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta.github.io/languages","stargazers_url":"https://api.github.com/repos/okta/okta.github.io/stargazers","contributors_url":"https://api.github.com/repos/okta/okta.github.io/contributors","subscribers_url":"https://api.github.com/repos/okta/okta.github.io/subscribers","subscription_url":"https://api.github.com/repos/okta/okta.github.io/subscription","commits_url":"https://api.github.com/repos/okta/okta.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta.github.io/merges","archive_url":"https://api.github.com/repos/okta/okta.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta.github.io/downloads","issues_url":"https://api.github.com/repos/okta/okta.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta.github.io/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta.github.io/deployments","created_at":"2013-06-25T23:22:38Z","updated_at":"2016-04-19T07:31:50Z","pushed_at":"2016-04-28T18:42:13Z","git_url":"git://github.com/okta/okta.github.io.git","ssh_url":"git@github.com:okta/okta.github.io.git","clone_url":"https://github.com/okta/okta.github.io.git","svn_url":"https://github.com/okta/okta.github.io","homepage":"http://developer.okta.com/","size":27511,"stargazers_count":12,"watchers_count":12,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":34,"mirror_url":null,"open_issues_count":14,"forks":34,"open_issues":14,"watchers":12,"default_branch":"master"}},"base":{"label":"okta:master","ref":"master","sha":"7b371cbff71eec2781f99e04b303e717cd7f1c7a","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":10953058,"name":"okta.github.io","full_name":"okta/okta.github.io","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta.github.io","description":"Okta Identity Platform API Docs and Developer Home","fork":false,"url":"https://api.github.com/repos/okta/okta.github.io","forks_url":"https://api.github.com/repos/okta/okta.github.io/forks","keys_url":"https://api.github.com/repos/okta/okta.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta.github.io/teams","hooks_url":"https://api.github.com/repos/okta/okta.github.io/hooks","issue_events_url":"https://api.github.com/repos/okta/okta.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta.github.io/events","assignees_url":"https://api.github.com/repos/okta/okta.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta.github.io/tags","blobs_url":"https://api.github.com/repos/okta/okta.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta.github.io/languages","stargazers_url":"https://api.github.com/repos/okta/okta.github.io/stargazers","contributors_url":"https://api.github.com/repos/okta/okta.github.io/contributors","subscribers_url":"https://api.github.com/repos/okta/okta.github.io/subscribers","subscription_url":"https://api.github.com/repos/okta/okta.github.io/subscription","commits_url":"https://api.github.com/repos/okta/okta.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta.github.io/merges","archive_url":"https://api.github.com/repos/okta/okta.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta.github.io/downloads","issues_url":"https://api.github.com/repos/okta/okta.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta.github.io/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta.github.io/deployments","created_at":"2013-06-25T23:22:38Z","updated_at":"2016-04-19T07:31:50Z","pushed_at":"2016-04-28T18:42:13Z","git_url":"git://github.com/okta/okta.github.io.git","ssh_url":"git@github.com:okta/okta.github.io.git","clone_url":"https://github.com/okta/okta.github.io.git","svn_url":"https://github.com/okta/okta.github.io","homepage":"http://developer.okta.com/","size":27511,"stargazers_count":12,"watchers_count":12,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":34,"mirror_url":null,"open_issues_count":14,"forks":34,"open_issues":14,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/226"},"html":{"href":"https://github.com/okta/okta.github.io/pull/226"},"issue":{"href":"https://api.github.com/repos/okta/okta.github.io/issues/226"},"comments":{"href":"https://api.github.com/repos/okta/okta.github.io/issues/226/comments"},"review_comments":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/226/comments"},"review_comment":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/okta/okta.github.io/pulls/226/commits"},"statuses":{"href":"https://api.github.com/repos/okta/okta.github.io/statuses/da58ffdc04592a424d9d2f1514ef3ece040994ca"}}}}