{"id":17540488,"url":"https://github.com/fromkk/oauth2client_ios","last_synced_at":"2025-03-29T04:41:19.924Z","repository":{"id":146698270,"uuid":"46338797","full_name":"fromkk/OAuth2client_iOS","owner":"fromkk","description":null,"archived":false,"fork":false,"pushed_at":"2015-11-17T10:20:50.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T14:27:38.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fromkk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-17T10:07:49.000Z","updated_at":"2015-11-17T10:08:58.000Z","dependencies_parsed_at":"2023-04-13T03:22:55.184Z","dependency_job_id":null,"html_url":"https://github.com/fromkk/OAuth2client_iOS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FOAuth2client_iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FOAuth2client_iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FOAuth2client_iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FOAuth2client_iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fromkk","download_url":"https://codeload.github.com/fromkk/OAuth2client_iOS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140537,"owners_count":20729797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-20T22:24:01.363Z","updated_at":"2025-03-29T04:41:19.903Z","avatar_url":"https://github.com/fromkk.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOS でOAuthライブラリを利用する方法\n\n今回選定したのは [NXOAuth2Client](https://github.com/nxtbgthng/OAuth2Client)  \n※基本的にライブラリのREADME.mdに書いてます\n\n## 初期設定\n\n```objective-c\n//AppDelegate.mとかでいいと思う\n[[NXOAuth2AccountStore sharedStore] setClientID:@\"xXxXxXxXxXxX\"\n                                             secret:@\"xXxXxXxXxXxX\"\n                                   authorizationURL:[NSURL URLWithString:@\"https://...your auth URL...\"]\n                                           tokenURL:[NSURL URLWithString:@\"https://...your token URL...\"]\n                                        redirectURL:[NSURL URLWithString:@\"https://...your redirect URL...\"]\n                                     forAccountType:@\"famm\"];\n```\n\n## ログイン\n\n```objective-c\n[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@\"famm\"\n                                                         username:aUserName\n                                                         password:aPassword];\n```\n\n## ログイン成功時\n\n`NSNotificationCenter` に `NXOAuth2AccountStoreAccountsDidChangeNotification` のキーで通知を受け取る  \nログインしたアカウントは `NSNotification` から `userInfo` の `NXOAuth2AccountStoreNewAccountUserInfoKey` キーで取得出来る  \n※[参考](http://hack.aipo.com/archives/8853/)\n\n## ログイン失敗時\n\n`NSNotificationCenter` に `addObserverForName:NXOAuth2AccountStoreDidFailToRequestAccessNotification` のキーで通知を受け取る\n\n## APIにリクエストする方法\n\n```objective-c\n[NXOAuth2Request performMethod:@\"GET\"\n                    onResource:[NSURL URLWithString:@\"https://...your service URL...\"]\n               usingParameters:nil\n                   withAccount:loginedAccount\n           sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) { // e.g., update a progress indicator }\n               responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error){\n                   // Process the response\n               }];\n```\n\n## 承認済みのURLを取得\n\n```objective-c\nNXOAuth2Request *theRequest = [[NXOAuth2Request alloc] initWithResource:[NSURL URLWithString:@\"https://...your service URL...\"]\n                                                                 method:@\"GET\"\n                                                             parameters:nil];\ntheRequest.account = // ... an loginedAccount\n\nNSURLRequest *sigendRequest = [theRequest signedURLRequest];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffromkk%2Foauth2client_ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffromkk%2Foauth2client_ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffromkk%2Foauth2client_ios/lists"}