/// <summary> /// Gets an authorization URL using the specified <var>state</var> and /// request the specified <var>scope</var>. /// </summary> /// <param name="state">A unique state for the request.</param> /// <param name="scope">The scope of your application.</param> public string GetAuthorizationUrl(string state, InstagramScope scope) { return(String.Format( "https://api.instagram.com/oauth/authorize/?client_id={0}&redirect_uri={1}&response_type=code&state={2}&scope={3}", HttpUtility.UrlEncode(ClientId), HttpUtility.UrlEncode(RedirectUri), HttpUtility.UrlEncode(state), HttpUtility.UrlEncode(scope.ToString().Replace(", ", "+").ToLower()) )); }
public static InstagramOAuthPreValueOptions Get(string contentTypeAlias, string propertyAlias) { IDictionary <string, string> prevalues = PreValueHelpers.GetPreValues(contentTypeAlias, propertyAlias); string config; prevalues.TryGetValue("config", out config); try { // Parse the JSON for the config/prevalues JObject obj = JObject.Parse(config); // Determine the scope InstagramScope scope = default(InstagramScope); foreach (string alias in (obj.GetString("scope") ?? "").Split(',')) { switch (alias) { case "public_content": scope |= InstagramScope.PublicContent; break; //case "follower_list": scope |= InstagramScope.FollowerList; break; case "comments": scope |= InstagramScope.Comments; break; case "relationships": scope |= InstagramScope.Relationships; break; case "likes": scope |= InstagramScope.Likes; break; } } // Initialize a new instance of the options class return(new InstagramOAuthPreValueOptions { JObject = obj, ClientId = obj.GetString("clientid"), ClientSecret = obj.GetString("clientsecret"), RedirectUri = obj.GetString("redirecturi"), Scope = scope, ScopeStr = obj.GetString("scope") ?? "" }); } catch (Exception) { return(new InstagramOAuthPreValueOptions()); } }
/// <summary> /// Gets an authorization URL using the specified <var>state</var> and /// request the specified <var>scope</var>. /// </summary> /// <param name="state">A unique state for the request.</param> /// <param name="scope">The scope of your application.</param> public string GetAuthorizationUrl(string state, InstagramScope scope) { return String.Format( "https://api.instagram.com/oauth/authorize/?client_id={0}&redirect_uri={1}&response_type=code&state={2}&scope={3}", HttpUtility.UrlEncode(ClientId), HttpUtility.UrlEncode(RedirectUri), HttpUtility.UrlEncode(state), HttpUtility.UrlEncode(scope.ToString().Replace(", ", "+").ToLower()) ); }