Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Account Authentication

Tobias Klika edited this page Apr 5, 2019 · 9 revisions

In order to communicate with a Pocket User, you will need a consumer key (which is generated by creating a new application on Pocket) and an Access Code.

The authentication is a 3-step process:

1) Generate authentication URI

Receive the request code and authentication URI from the library by calling string GetRequestCode():

string requestCode = await _client.GetRequestCode();
// 0f453f2d-1605-8584-28fd-39af8e
Uri authenticationUri = _client.GenerateAuthenticationUri();
// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&redirect_uri=http%253a%252f%252fceecore.com

The request code is stored internally, but you can also provide it as param in GenerateAuthenticationUri(string requestCode = null).

Registration

If you want to register a user, you have to follow the same authentication process as described here, but replace the GenerateAuthenticationUri method with the GenerateRegistrationUri method (available since 3.1.0).

After redirecting to the generated URI, the user can signup and will be promped to the auth screen afterwards (as described in Step 2).

2) Redirect to Pocket

Next you need to redirect the user to the authenticationUri, which displays a prompt to grant permissions for the application (see image). After the user granted or denied, he/she is redirected to the callbackUri.

authentication screen

3) Get Access Code and account data

Call Task<PocketUser> GetUser(string requestCode = null)

PocketUser user = await _client.GetUser();
// PocketUser:
//  [Code] fa8bfc16-69b3-4d22-7db7-84a58d
//  [Username] myUsername
//  [...] other user data

Again, the received access code (PocketUser.Code) is stored internally. Note that GetUser can only be called with an existing request code. If you need to re-authenticate a user, start again with Step 1).

Important

Be sure to permanently store the Access Code for your user.
Without it you would always have to redo the authentication process.

Clone this wiki locally