/// <summary> /// Gets an authorization URL using the specified <paramref name="state"/> and request the specified /// <paramref name="scope"/>. /// </summary> /// <param name="state">A unique state for the request.</param> /// <param name="scope">The scope of your application.</param> /// <returns>The authorization URL.</returns> public virtual string GetAuthorizationUrl(string state, params string[] scope) { // Some validation if (String.IsNullOrWhiteSpace(ClientId)) { throw new PropertyNotSetException("ClientId"); } if (String.IsNullOrWhiteSpace(RedirectUri)) { throw new PropertyNotSetException("RedirectUri"); } // Do we have a valid "state" ? if (String.IsNullOrWhiteSpace(state)) { throw new ArgumentNullException("state", "A valid state should be specified as it is part of the security of OAuth 2.0."); } // Construct the query string IHttpQueryString query = new SocialHttpQueryString(); query.Add("client_id", ClientId); query.Add("redirect_uri", RedirectUri); query.Add("response_type", "code"); query.Add("state", state); // Append the scope (if specified) if (scope != null && scope.Length > 0) { query.Add("scope", String.Join(" ", scope)); } // Construct the authorization URL return("https://api.instagram.com/oauth/authorize/?" + query.ToString()); }