C# Class PinSharp.PinterestAuthClient

Datei anzeigen Open project: Krusen/PinSharp

Public Methods

Method Description
BuildAuthorizationUrl ( string clientId, string redirectUri, Scopes scopes ) : string

Generates a login URL with the required parameters. Users will need to visit this URL to authorize your app to use the API on their behalf.

If they accept they will be redirected to the redirectUri with two query string parameters - "state" and "code".

Call BuildAuthorizationUrl if you want to specify the state value yourself to be able to prevent spoofing.

"code" is used with GetAccessTokenAsync to get an access token to use with PinterestClient.

BuildAuthorizationUrl ( string clientId, string redirectUri, Scopes scopes, string state ) : string

Generates a login URL with the required parameters. Users will need to visit this URL to authorize your app to use the API on their behalf.

If they accept they will be redirected to the redirectUri with two query string parameters - "state" and "code".

"state" verifies that this comes from you. "code" is used with GetAccessTokenAsync to get an access token to use with PinterestClient.

CreateRandomState ( int length = 10 ) : string

Generates a random string that you can use to verify that the redirect back to your site or app wasn't spoofed.

Pass this to BuildAuthorizationUrl to get the correct login URL.

GetAccessTokenAsync ( string clientId, string clientSecret, string code, string apiVersion = "v1" ) : Task

Gets an access token which you can then use with PinterestClient.

Private Methods

Method Description
GetScope ( Scopes scopes ) : string

Method Details

BuildAuthorizationUrl() public static method

Generates a login URL with the required parameters. Users will need to visit this URL to authorize your app to use the API on their behalf.

If they accept they will be redirected to the redirectUri with two query string parameters - "state" and "code".

Call BuildAuthorizationUrl if you want to specify the state value yourself to be able to prevent spoofing.

"code" is used with GetAccessTokenAsync to get an access token to use with PinterestClient.

public static BuildAuthorizationUrl ( string clientId, string redirectUri, Scopes scopes ) : string
clientId string The Client ID (also known as App ID) of your app. See https://developers.pinterest.com/apps/
redirectUri string /// The URL you want your user to be redirected to after authorizing your app. /// The code needed for will be added as query string parameter "code". ///
scopes Scopes The scopes you want to request from the user.
return string

BuildAuthorizationUrl() public static method

Generates a login URL with the required parameters. Users will need to visit this URL to authorize your app to use the API on their behalf.

If they accept they will be redirected to the redirectUri with two query string parameters - "state" and "code".

"state" verifies that this comes from you. "code" is used with GetAccessTokenAsync to get an access token to use with PinterestClient.

public static BuildAuthorizationUrl ( string clientId, string redirectUri, Scopes scopes, string state ) : string
clientId string The Client ID (also known as App ID) of your app. See https://developers.pinterest.com/apps/
redirectUri string /// The URL you want your user to be redirected to after authorizing your app. /// The code needed for will be added as query string parameter "code". ///
scopes Scopes The scopes you want to request from the user.
state string A string that is added to as query string parameter "state". This is to prevent spoofing.
return string

CreateRandomState() public static method

Generates a random string that you can use to verify that the redirect back to your site or app wasn't spoofed.

Pass this to BuildAuthorizationUrl to get the correct login URL.

public static CreateRandomState ( int length = 10 ) : string
length int The length of the random string.
return string

GetAccessTokenAsync() public static method

Gets an access token which you can then use with PinterestClient.
public static GetAccessTokenAsync ( string clientId, string clientSecret, string code, string apiVersion = "v1" ) : Task
clientId string The Client ID (also known as App ID) of your app. See https://developers.pinterest.com/apps/
clientSecret string The Client secret (also known as App secret) of your app. See https://developers.pinterest.com/apps/
code string The code that was passed to your redirectUri as a query string parameter.
apiVersion string The API version. Defaults to "v1" if left out.
return Task