Вопрос

I'm working on a project, used many of the code given in the sample app but can't figure out why my application does not store the oauth token. As I said I've used a lot of code from the ios sdk sample app and the sample app itself does work 100%...

My log is very messy to, do you see the problem?

edit:

I have 2 step verification enabled, and every time I log in, I get 2 e-mails from box. One saying that I've had a box login from iPhone mobile browser, and one saying that I've had a box login from the application I registered at developers.box.com.

This is my output:

2014-02-25 08:09:39.055 SidebarDemo[4005:3b07] +[BoxAPIOperation globalAPIOperationNetworkThreadEntryPoint:]: <NSThread: 0x9fa2d80>{name = Box API Operation Thread, num = 2} started
2014-02-25 08:09:39.054 SidebarDemo[4005:70b] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIJSONOperation: 0x9d5ceb0> GET https://api.box.com/2.0/folders/0 on global queue
2014-02-25 08:09:39.056 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d5ceb0> GET https://api.box.com/2.0/folders/0 was started
2014-02-25 08:09:39.063 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIJSONOperation: 0x9d5ceb0> GET https://api.box.com/2.0/folders/0
2014-02-25 08:09:39.068 SidebarDemo[4005:70b] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIJSONOperation: 0x9d68fb0> GET https://api.box.com/2.0/folders/0/items on global queue
2014-02-25 08:09:39.866 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: OAuth2 access token is expired.
2014-02-25 08:09:39.866 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: Re-enqueueing operation that failed to authenticate
2014-02-25 08:09:39.867 SidebarDemo[4005:3b07] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIJSONOperation: 0x9c81680> GET https://api.box.com/2.0/folders/0 on global queue
2014-02-25 08:09:39.867 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: Attempting automatic OAuth2 token refresh
2014-02-25 08:09:39.867 SidebarDemo[4005:3b07] -[BoxParallelOAuth2Session performRefreshTokenGrant:]: access token expired: (null)
2014-02-25 08:09:39.868 SidebarDemo[4005:3b07] -[BoxParallelOAuth2Session performRefreshTokenGrant:]: refreshing tokens
2014-02-25 08:09:39.868 SidebarDemo[4005:3b07] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token on global queue
2014-02-25 08:09:39.869 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d5ceb0> GET https://api.box.com/2.0/folders/0 did finsh loading
2014-02-25 08:09:39.869 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d5ceb0> GET https://api.box.com/2.0/folders/0 finished with state 3
2014-02-25 08:09:39.870 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token was started
2014-02-25 08:09:39.870 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token
2014-02-25 08:09:40.163 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token did finsh loading
2014-02-25 08:09:40.163 SidebarDemo[4005:3b07] Refresh failed. User is logged out. Initiate login flow
2014-02-25 08:09:40.167 SidebarDemo[4005:3b07] -[BoxAPIQueueManager OAuth2OperationDidComplete:]: <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token completed. Removing from set of OAuth2 dependencies
2014-02-25 08:09:40.167 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9c85920> POST https://api.box.com/oauth2/token finished with state 3
2014-02-25 08:09:40.168 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d68fb0> GET https://api.box.com/2.0/folders/0/items was started
2014-02-25 08:09:40.168 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIJSONOperation: 0x9d68fb0> GET https://api.box.com/2.0/folders/0/items
2014-02-25 08:09:40.422 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: OAuth2 access token is expired.
2014-02-25 08:09:40.423 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: Re-enqueueing operation that failed to authenticate
2014-02-25 08:09:40.423 SidebarDemo[4005:3b07] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIJSONOperation: 0x9faa340> GET https://api.box.com/2.0/folders/0/items on global queue
2014-02-25 08:09:40.424 SidebarDemo[4005:3b07] -[BoxAPIAuthenticatedOperation connection:didReceiveResponse:]: Attempting automatic OAuth2 token refresh
2014-02-25 08:09:40.424 SidebarDemo[4005:3b07] -[BoxParallelOAuth2Session performRefreshTokenGrant:]: access token expired: (null)
2014-02-25 08:09:40.424 SidebarDemo[4005:3b07] -[BoxParallelOAuth2Session performRefreshTokenGrant:]: refreshing tokens
2014-02-25 08:09:40.425 SidebarDemo[4005:3b07] -[BoxParallelAPIQueueManager enqueueOperation:]: enqueued <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token on global queue
2014-02-25 08:09:40.425 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d68fb0> GET https://api.box.com/2.0/folders/0/items did finsh loading
2014-02-25 08:09:40.521 SidebarDemo[4005:3b07] folder items error: Error Domain=com.box.sdk.errordomain Code=20000 "The operation couldn’t be completed. (com.box.sdk.errordomain error 20000.)"
2014-02-25 08:09:40.521 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIJSONOperation: 0x9d68fb0> GET https://api.box.com/2.0/folders/0/items finished with state 3
2014-02-25 08:09:40.521 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token was started
2014-02-25 08:09:40.522 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token
2014-02-25 08:09:40.525 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: Web view should start request <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } with navigation type 5
2014-02-25 08:09:40.526 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: Request Headers 
{
    Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    "User-Agent" = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B508";
}
2014-02-25 08:09:40.528 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: Was not authenticated, launching URLConnection and not loading the request in the web view
2014-02-25 08:09:40.528 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: URLConnection is <NSURLConnection: 0x9c9ba90> { request: <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } }
2014-02-25 08:09:40.802 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token did finsh loading
2014-02-25 08:09:40.803 SidebarDemo[4005:3b07] Refresh failed. User is logged out. Initiate login flow
2014-02-25 08:09:40.804 SidebarDemo[4005:70b] Warning: Attempt to present <BoxAuthorizationNavigationController: 0x9e6b710> on <SWRevealViewController: 0x9fa5840> whose view is not in the window hierarchy!
2014-02-25 08:09:40.805 SidebarDemo[4005:70b] -[BoxAuthorizationViewController clearCookies]: Attempt to clear cookies
2014-02-25 08:09:40.806 SidebarDemo[4005:3b07] -[BoxAPIQueueManager OAuth2OperationDidComplete:]: <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token completed. Removing from set of OAuth2 dependencies
2014-02-25 08:09:40.806 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIOAuth2ToJSONOperation: 0x9d51130> POST https://api.box.com/oauth2/token finished with state 3
2014-02-25 08:09:40.807 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIJSONOperation: 0x9c81680> GET https://api.box.com/2.0/folders/0 was started
2014-02-25 08:09:40.807 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIJSONOperation: 0x9c81680> GET https://api.box.com/2.0/folders/0
2014-02-25 08:09:40.940 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connection:willSendRequestForAuthenticationChallenge:]: connection <NSURLConnection: 0x9c9ba90> { request: <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } } did receive authentication challenge <NSURLAuthenticationChallenge: 0x9fb1190>
2014-02-25 08:09:40.940 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connection:willSendRequestForAuthenticationChallenge:]: Server trust authentication challenge
2014-02-25 08:09:40.942 SidebarDemo[4005:70b] -[BoxAuthorizationViewController completeServerTrustAuthenticationChallenge:shouldTrust:]: Trust the host.
2014-02-25 08:09:41.046 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIJSONOperation: 0x9c81680> GET https://api.box.com/2.0/folders/0 did finsh loading
2014-02-25 08:09:41.046 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIJSONOperation: 0x9c81680> GET https://api.box.com/2.0/folders/0 finished with state 3
2014-02-25 08:09:41.047 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: BoxAPIOperation <BoxAPIJSONOperation: 0x9faa340> GET https://api.box.com/2.0/folders/0/items was started
2014-02-25 08:09:41.047 SidebarDemo[4005:3b07] -[BoxAPIOperation executeOperation]: Starting <BoxAPIJSONOperation: 0x9faa340> GET https://api.box.com/2.0/folders/0/items
2014-02-25 08:09:41.280 SidebarDemo[4005:3b07] -[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation <BoxAPIJSONOperation: 0x9faa340> GET https://api.box.com/2.0/folders/0/items did finsh loading
2014-02-25 08:09:41.280 SidebarDemo[4005:3b07] folder items error: Error Domain=com.box.sdk.errordomain Code=20002 "The operation couldn’t be completed. (com.box.sdk.errordomain error 20002.)"
2014-02-25 08:09:41.281 SidebarDemo[4005:3b07] -[BoxAPIOperation finish]: BoxAPIOperation <BoxAPIJSONOperation: 0x9faa340> GET https://api.box.com/2.0/folders/0/items finished with state 3
2014-02-25 08:09:41.534 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connection:didReceiveResponse:]: Connection <NSURLConnection: 0x9c9ba90> { request: <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } } did receive response <NSHTTPURLResponse: 0x9c5d260> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } { status code: 200, headers {
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html; charset=UTF-8";
    Date = "Tue, 25 Feb 2014 07:09:41 GMT";
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    Pragma = "no-cache";
    Server = nginx;
    "Set-Cookie" = "z=dns8qfgvluf8bonm9e7j28h4i6; path=/; domain=.box.com; secure; HttpOnly, presentation=desktop; path=/; domain=.box.com";
    "Transfer-Encoding" = Identity;
} }
2014-02-25 08:09:41.535 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connection:didReceiveResponse:]: HTTP Headers were: {
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html; charset=UTF-8";
    Date = "Tue, 25 Feb 2014 07:09:41 GMT";
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    Pragma = "no-cache";
    Server = nginx;
    "Set-Cookie" = "z=dns8qfgvluf8bonm9e7j28h4i6; path=/; domain=.box.com; secure; HttpOnly, presentation=desktop; path=/; domain=.box.com";
    "Transfer-Encoding" = Identity;
}
2014-02-25 08:09:41.536 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connection:didReceiveData:]: Connection <NSURLConnection: 0x9c9ba90> { request: <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } } did receive 8090 bytes of data
2014-02-25 08:09:41.536 SidebarDemo[4005:70b] -[BoxAuthorizationViewController connectionDidFinishLoading:]: Connection <NSURLConnection: 0x9c9ba90> { request: <NSMutableURLRequest: 0x9fafaf0> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } } did finish loading. Requesting that the webview load the data (8090 bytes) with reponse <NSHTTPURLResponse: 0x9c5d260> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } { status code: 200, headers {
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html; charset=UTF-8";
    Date = "Tue, 25 Feb 2014 07:09:41 GMT";
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    Pragma = "no-cache";
    Server = nginx;
    "Set-Cookie" = "z=dns8qfgvluf8bonm9e7j28h4i6; path=/; domain=.box.com; secure; HttpOnly, presentation=desktop; path=/; domain=.box.com";
    "Transfer-Encoding" = Identity;
} }
2014-02-25 08:09:41.573 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: Web view should start request <NSMutableURLRequest: 0x9d67f00> { URL: https://api.box.com/oauth2/authorize?response_type=code&client_id=eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp&state=ok&redirect_uri=boxsdk-eh3fjhsm8i5n1gyffntxa8mr3ghlnqwp%3A%2F%2Fboxsdkoauth2redirect } with navigation type 5
2014-02-25 08:09:41.573 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webView:shouldStartLoadWithRequest:navigationType:]: Request Headers 
{
    Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    "User-Agent" = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B508";
}
2014-02-25 08:09:41.574 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webViewDidStartLoad:]
2014-02-25 08:09:41.676 SidebarDemo[4005:70b] -[BoxAuthorizationViewController webViewDidFinishLoad:]
Это было полезно?

Решение

My keychain script didn't work properly it had nothing to do with other files. In my case in stead of creating a new project and implementing the BoxSDK, use the BoxSDK sample app to code everything else into it.

:)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top