<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token? in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/545112#M2150</link>
    <description>&lt;P&gt;We've added &lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c/commit/f03fe37baac40939bb048394192e8df958247494#diff-9a3ae2876fe7f38ea6edb6a0e9d68ed52b5f8a1fb8d7b5a557f01f17c7955ba3R43" target="_self"&gt;the ability to supply a DBAccessToken (which can contain a refresh token) directly&lt;/A&gt; which is available as of v6.2.0. Please give that a try and let us know if that doesn't work for you. Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 16:25:36 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2021-09-15T16:25:36Z</dc:date>
    <item>
      <title>[ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540186#M2092</link>
      <description>&lt;P&gt;Quite likely missing something obvious, trying to migrate to the short-lived access tokens, so first change the authorize:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;authorizeFromControllerV2&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;save the refresh token:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;_dropbox.accessToken = authResult.accessToken.accessToken;
_dropbox.refreshToken = authResult.accessToken.refreshToken;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;at a later date, init the UserClient&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DBUserClient *dropboxClient = [[DBUserClient alloc] initWithAccessToken:_dropbox.accessToken];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;But we can't supply a refresh token with this init method, so we should use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;initWithAccessTokenProvider:&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;and implement id&amp;lt;DBAccessTokenProvider&amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;/// Protocol for objects that provide an access token and offer a way to refresh (short-lived) token.
@protocol DBAccessTokenProvider &amp;lt;NSObject&amp;gt;

/// Returns an access token for making user auth API calls.
@property (nonatomic, readonly) NSString *accessToken;

/// This refreshes the access token if it's expired or about to expire.
/// The refresh result will be passed back via the completion block.
- (void)refreshAccessTokenIfNecessary:(DBOAuthCompletion)completion;

@end&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I notice this is already implemented within the SDK in&amp;nbsp;"DBAccessTokenProvider+Internal.h" but this isn't exposed, are we not expected to use this init? Or is the play to just init with a normal accessToken and capture an error then refresh manually ourselves? Seems odd seeing as it's already in the SDK. What am I missing?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 07:06:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540186#M2092</guid>
      <dc:creator>Samikay</dc:creator>
      <dc:date>2021-08-20T07:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540246#M2093</link>
      <description>&lt;P&gt;You shouldn't actually have to do most of this work in your own code. As long as you &lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c#begin-the-authorization-flow" target="_self"&gt;use the authorizeFromControllerV2 method to start the authorization flow as shown here&lt;/A&gt;, and &lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c#handle-redirect-back-into-sdk" target="_self"&gt;then receive the result as shown here&lt;/A&gt;, the SDK would then handle the token storage and refresh process for you automatically. You would &lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c#try-some-api-requests" target="_self"&gt;use the supplied authorizedClient as shown here&lt;/A&gt; to perform whatever calls you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give that flow a try and let me know if it's not working. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 14:45:37 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540246#M2093</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-08-20T14:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540270#M2095</link>
      <description>&lt;P&gt;Hmm, unfortunately for our use case we have the user able to auth once on web/Android/iOS and be able to upload on any of those devices by sharing the Dropbox access token when they log into their (our app's) account (so we handle the storage of the tokens instead of the SDK and then init DBUserClients [or equivalent] on each platform), with long-lived tokens this was easy and worked nicely, short-lived makes it a tad more interesting. Based on your reply I'll yoink the internal code out and play around &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@C416A51F5C88BC4C321947886FE0A167/emoticons/1f61b.png" alt=":face_with_tongue:" title=":face_with_tongue:" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 16:40:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540270#M2095</guid>
      <dc:creator>Samikay</dc:creator>
      <dc:date>2021-08-20T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540273#M2096</link>
      <description>&lt;P&gt;Ah, I should mention when I implemented it in Android it was quite simple because DbxCredential takes a refresh token as an init parameter:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;new DbxCredential(accessToken, 0L, refreshToken, DROPBOX_APP_KEY)
return new DbxClientV2(dropboxRequestConfig(), credential);&lt;/LI-CODE&gt;&lt;P&gt;Hence why I was looking for the iOS equivalent &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@13532C4C3505179FBF012F1C117AE2EB/emoticons/1f604.png" alt=":grinning_face_with_smiling_eyes:" title=":grinning_face_with_smiling_eyes:" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 16:43:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540273#M2096</guid>
      <dc:creator>Samikay</dc:creator>
      <dc:date>2021-08-20T16:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540307#M2097</link>
      <description>&lt;P&gt;I see, thanks for clarifying! I'll send this along as a request to the team to see if we can publicly expose something to do that in the Objective-C SK.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 19:10:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540307#M2097</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-08-20T19:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540356#M2098</link>
      <description>&lt;P&gt;Thanks Greg, I imagine it won't be too bad as the code is already there from what I can see although that is the definition of "famous last developer words". Cheers!&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 01:39:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/540356#M2098</guid>
      <dc:creator>Samikay</dc:creator>
      <dc:date>2021-08-21T01:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: [ObjC] Having trouble init'ing a UserClient with the new refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/545112#M2150</link>
      <description>&lt;P&gt;We've added &lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c/commit/f03fe37baac40939bb048394192e8df958247494#diff-9a3ae2876fe7f38ea6edb6a0e9d68ed52b5f8a1fb8d7b5a557f01f17c7955ba3R43" target="_self"&gt;the ability to supply a DBAccessToken (which can contain a refresh token) directly&lt;/A&gt; which is available as of v6.2.0. Please give that a try and let us know if that doesn't work for you. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 16:25:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/ObjC-Having-trouble-init-ing-a-UserClient-with-the-new-refresh/m-p/545112#M2150</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-09-15T16:25:36Z</dc:date>
    </item>
  </channel>
</rss>

